2

I have a markdown file checked into GitHub, and in this file I want to link to the following URL:

https://query.wikidata.org/#%23 Diplomatic missions with no operator.%0ASELECT DISTINCT%0A%09%3Fwikidata%0A%09(SAMPLE(%3Ftype_label) as %3Ftype)%0A%09(SAMPLE(%3Fcountry_label) as %3Fcountry)%09%0AWHERE {%0A%09{ %3Fwikidata p%3AP31%2Fps%3AP31%2Fwdt%3AP279* wd%3AQ3917681. } UNION { %3Fwikidata p%3AP31%2Fps%3AP31%2Fwdt%3AP279* wd%3AQ7843791. } %23 Embassy or consulate%0A%09%3Fwikidata p%3AP31%2Fps%3AP31 %3FtypeId. %3FtypeId wdt%3AP279* wd%3AQ43229. %3FtypeId rdfs%3Alabel %3Ftype_label. FILTER (lang(%3Ftype_label) %3D "en").%0A%09%3Fwikidata wdt%3AP131* %3Farea .%0A%09%3Farea wdt%3AP17 %3FcountryId. %3FcountryId rdfs%3Alabel %3Fcountry_label. FILTER (lang(%3Fcountry_label) %3D "en").%0A%09MINUS{%0A %09{%3Fwikidata wdt%3AP137 %3FoperatorId.}%0A %09UNION%0A%09%09{%3Fwikidata p%3AP31%2Fps%3AP31 %3Fnunciature. %3Fnunciature wdt%3AP137 %3FoperatorId.}%0A }%0A%09MINUS {%3Fwikidata wdt%3AP582 %3Fendtime.}%09 MINUS {%3Fwikidata wdt%3AP582 %3FdissolvedOrAbolished.}%0A%09MINUS {%3Fwikidata p%3AP31 %3FinstanceStatement. %3FinstanceStatement pq%3AP582 %3FendtimeQualifier.}%0A%09%23 Only countries that still contain the location (ex%3A Pristina is not in the "Province of Kosovo" because it does not exist anymore.%0A%09FILTER NOT EXISTS {%0A%09%09%3Fwikidata p%3AP131%2F(ps%3AP131%2Fp%3AP131)* %3Fstatement.%0A%09%09%3Fstatement ps%3AP131 %3Farea.%0A%09%09%3Fwikidata p%3AP131%2F(ps%3AP131%2Fp%3AP131)* %3FintermediateStatement.%0A%09%09%3FintermediateStatement (ps%3AP131%2Fp%3AP131)* %3Fstatement.%0A%09%09%3FintermediateStatement pq%3AP582 %3FendTime.%0A%09}%0A} GROUP BY %3Fwikidata

Unfortunately, GitHub fails to understand the link, the link appears as text.
I tried replacing all spaces with %20, it does not work either:

[Find embassies lacking an operator](https://query.wikidata.org/#%23%20Diplomatic%20missions%20with%20no%20operator.%0ASELECT%20DISTINCT%0A%09%3Fwikidata%0A%09(SAMPLE(%3Ftype_label)%20as%20%3Ftype)%0A%09(SAMPLE(%3Fcountry_label)%20as%20%3Fcountry)%09%0AWHERE%20{%0A%09{%20%3Fwikidata%20p%3AP31%2Fps%3AP31%2Fwdt%3AP279*%20wd%3AQ3917681.%20}%20UNION%20{%20%3Fwikidata%20p%3AP31%2Fps%3AP31%2Fwdt%3AP279*%20wd%3AQ7843791.%20}%20%23%20Embassy%20or%20consulate%0A%09%3Fwikidata%20p%3AP31%2Fps%3AP31%20%3FtypeId.%20%3FtypeId%20wdt%3AP279*%20wd%3AQ43229.%20%3FtypeId%20rdfs%3Alabel%20%3Ftype_label.%20FILTER%20(lang(%3Ftype_label)%20%3D%20"en").%0A%09%3Fwikidata%20wdt%3AP131*%20%3Farea%20.%0A%09%3Farea%20wdt%3AP17%20%3FcountryId.%20%3FcountryId%20rdfs%3Alabel%20%3Fcountry_label.%20FILTER%20(lang(%3Fcountry_label)%20%3D%20"en").%0A%09MINUS{%0A%20%09{%3Fwikidata%20wdt%3AP137%20%3FoperatorId.}%0A%20%09UNION%0A%09%09{%3Fwikidata%20p%3AP31%2Fps%3AP31%20%3Fnunciature.%20%3Fnunciature%20wdt%3AP137%20%3FoperatorId.}%0A%20}%0A%09MINUS%20{%3Fwikidata%20wdt%3AP582%20%3Fendtime.}%09%20MINUS%20{%3Fwikidata%20wdt%3AP582%20%3FdissolvedOrAbolished.}%0A%09MINUS%20{%3Fwikidata%20p%3AP31%20%3FinstanceStatement.%20%3FinstanceStatement%20pq%3AP582%20%3FendtimeQualifier.}%0A%09%23%20Only%20countries%20that%20still%20contain%20the%20location%20(ex%3A%20Pristina%20is%20not%20in%20the%20"Province%20of%20Kosovo"%20because%20it%20does%20not%20exist%20anymore.%0A%09FILTER%20NOT%20EXISTS%20{%0A%09%09%3Fwikidata%20p%3AP131%2F(ps%3AP131%2Fp%3AP131)*%20%3Fstatement.%0A%09%09%3Fstatement%20ps%3AP131%20%3Farea.%0A%09%09%3Fwikidata%20p%3AP131%2F(ps%3AP131%2Fp%3AP131)*%20%3FintermediateStatement.%0A%09%09%3FintermediateStatement%20(ps%3AP131%2Fp%3AP131)*%20%3Fstatement.%0A%09%09%3FintermediateStatement%20pq%3AP582%20%3FendTime.%0A%09}%0A}%20GROUP%20BY%20%3Fwikidata)

How to escape the URL so that GitHub markdown correctly creates the link?

1

You'll need to encode your parentheses in order for GitHub to correctly parse the link. You can see this by typing the bare URL into the GitHub editor. GitHub will underline a natively-typed link, but in yours it only underlines up to the first open parentheses:

enter image description here

Replacing your open parentheses ( with %28 and your close parentheses ) with %29 will allow GitHub to correctly process the link. The updated URL would be:

https://query.wikidata.org/#%23%20Diplomatic%20missions%20with%20no%20operator.%0ASELECT%20DISTINCT%0A%09%3Fwikidata%0A%09%28SAMPLE%28%3Ftype_label%29%20as%20%3Ftype%29%0A%09%28SAMPLE%28%3Fcountry_label%29%20as%20%3Fcountry%29%09%0AWHERE%20{%0A%09{%20%3Fwikidata%20p%3AP31%2Fps%3AP31%2Fwdt%3AP279*%20wd%3AQ3917681.%20}%20UNION%20{%20%3Fwikidata%20p%3AP31%2Fps%3AP31%2Fwdt%3AP279*%20wd%3AQ7843791.%20}%20%23%20Embassy%20or%20consulate%0A%09%3Fwikidata%20p%3AP31%2Fps%3AP31%20%3FtypeId.%20%3FtypeId%20wdt%3AP279*%20wd%3AQ43229.%20%3FtypeId%20rdfs%3Alabel%20%3Ftype_label.%20FILTER%20%28lang%28%3Ftype_label%29%20%3D%20"en"%29.%0A%09%3Fwikidata%20wdt%3AP131*%20%3Farea%20.%0A%09%3Farea%20wdt%3AP17%20%3FcountryId.%20%3FcountryId%20rdfs%3Alabel%20%3Fcountry_label.%20FILTER%20%28lang%28%3Fcountry_label%29%20%3D%20"en"%29.%0A%09MINUS{%0A%20%09{%3Fwikidata%20wdt%3AP137%20%3FoperatorId.}%0A%20%09UNION%0A%09%09{%3Fwikidata%20p%3AP31%2Fps%3AP31%20%3Fnunciature.%20%3Fnunciature%20wdt%3AP137%20%3FoperatorId.}%0A%20}%0A%09MINUS%20{%3Fwikidata%20wdt%3AP582%20%3Fendtime.}%09%20MINUS%20{%3Fwikidata%20wdt%3AP582%20%3FdissolvedOrAbolished.}%0A%09MINUS%20{%3Fwikidata%20p%3AP31%20%3FinstanceStatement.%20%3FinstanceStatement%20pq%3AP582%20%3FendtimeQualifier.}%0A%09%23%20Only%20countries%20that%20still%20contain%20the%20location%20%28ex%3A%20Pristina%20is%20not%20in%20the%20"Province%20of%20Kosovo"%20because%20it%20does%20not%20exist%20anymore.%0A%09FILTER%20NOT%20EXISTS%20{%0A%09%09%3Fwikidata%20p%3AP131%2F%28ps%3AP131%2Fp%3AP131%29*%20%3Fstatement.%0A%09%09%3Fstatement%20ps%3AP131%20%3Farea.%0A%09%09%3Fwikidata%20p%3AP131%2F%28ps%3AP131%2Fp%3AP131%29*%20%3FintermediateStatement.%0A%09%09%3FintermediateStatement%20%28ps%3AP131%2Fp%3AP131%29*%20%3Fstatement.%0A%09%09%3FintermediateStatement%20pq%3AP582%20%3FendTime.%0A%09}%0A}%20GROUP%20BY%20%3Fwikidata

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.