There are some limitations at this point. You need to use the same abbreviations that are used on SuttaCentral. And of course if the citations are bad, then the links will be bad. It also doesnât accommodate ranges.
So, if you look at the post that inspired me to make it, the Udana citations wonât work because it says âUdanaâ instead of âUdâ. And the Iti links wonât work because they are in the form of chapter and sutta rather than suttas 1â112.
Any feedback would be most welcome. Itâs mostly a learning project for me, so Iâd be interested in feature requests.
This is awesome.
This is awesome. So if I want to link to SN 2.12, and compare this with Snp 2.12, theyâll both work.
We should add this to Discourse! Can you turn your widget into a Discourse plugin?
Just to note, canonically URLs on SC are all lowercase. Uppercase works, but in the past it didnât, so if you can convert to all-lowercase itâd be more robust.
At the moment it is not really anything more than a regex search and replace. Accommodating the other two number formats for Iti and Ud will make it slightly more complex.
Done!
OK, I have the issue with the Iti and the Ud sorted. No matter what format those citations are in, it should give you a working link (assuming it is a valid citation)
I just added a preview for the html result so users can make sure all the links work. (Iâm assuming that the other formats would produce the same preview)
Bhante @Sujato, I think this is stable enough that itâs ready to be added to the âSC Awesomeâ page if you think it will be helpful.
Iâd recommend not including Sn as a possible citation for Saášyutta NikÄya since it is a standard (if not outdated in a digital world) abbreviation for Sutta NipÄta. You would rarely see it for SN. In fact, I wouldnât bother with Dn, Mn, or An either.
Is there a tool you used to create that? Itâs amazing.
Yes, if at all possible colons as well as periods should be acceptable as separators.
I think the very nature of code blocks is that nothing should touch them, eh? I believe that the default behaviour of the code being used ignores things inside of code blocks.
By work, you mean�
Personally, I think it would be find to require a standard capitalization (e.g. DN, AN, Snp, Dhp). That might even give people the option of not having citations linked up automatically if they desired.
My idea here is simply to think of edge cases. What the behavior âshouldâ be in these cases is up to yâall! But, fwiw, I agree that code block refs should probably be left unlinkafied
Yes, several of these do break the linkup tool. I didnât really consider people pasting in html text. I should probably just say that itâs unsupported/use at your own risk for linking up code. I think there might be too many edge cases to deal with.
Ranges are already unsupported. The link will be created for the first part of the range.
Implementation on the forum is simplified due to the current constraints with using |, so the rule here (for the time being) is to simply match all case insensitive strings (which will also match dN 1).
Added support for legacy : notation for SN, AN, Ud and Snp.
Rules using : as a separator are not exact (i.e. they will map some non-existent notations to invalid links). Use $3.$4 for substitution and map each regex below to corresponding SC id: