Citation Link Up tool 🔧 to turn citations into links for a block of text

Bhante, you can try these for size. The regex rules below will produce only valid SC links!

Use $2 for substitution and map each regex below to corresponding SC id:

  • \b(DN...)\b → [DN $2](https://suttacentral.net/dn$2/en/sujato)
  • …
  • \b(Ud...)\b → [Ud $2](https://suttacentral.net/ud$2/en/sujato)
\b(DN|Dn|dn)\s?([1-9]|[1-2][0-9]|3[0-4])\b

\b(MN|Mn|mn)\s?([1-9]|[1-9][0-9]|1[0-4][0-9]|15[0-2])\b

\b(AN|An|an)\s?((1|8)\.([1-9]|[1-9][0-9]|[1-5][0-9][0-9]|6[0-1][0-9]|62[0-7])|2\.([1-9]|[1-9][0-9]|[1-3][0-9][0-9]|4[0-7][0-9])|3\.([1-9]|[1-9][0-9]|[1-2][0-9][0-9]|3[0-4][0-9]|35[0-2])|4\.([1-9]|[1-9][0-9]|[1-6][0-9][0-9]|7[0-7][0-9]|78[0-3])|5\.([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|10[0-9][0-9]|11[0-4][0-9]|115[0-2])|6\.([1-9]|[1-9][0-9]|[1-5][0-9][0-9]|6[0-4][0-9])|7\.([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|10[0-9][0-9]|11[0-1][0-9]|112[0-4])|9\.([1-9]|[1-9][0-9]|[1-3][0-9][0-9]|4[0-2][0-9]|43[0-2])|10\.([1-9]|[1-9][0-9]|[1-6][0-9][0-9]|7[0-3][0-9]|74[0-6])|11\.([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|10[0-9][0-9]|11[0-4][0-9]|115[0-1]))\b

\b(SN|Sn|sn)\s?(1\.([1-9]|[1-7][0-9]|8[0-1])|2\.([1-9]|[1-2][0-9]|30)|(3|4|11)\.([1-9]|1[0-9]|2[0-5])|(5|2[5-8]|41)\.([1-9]|10)|6\.([1-9]|1[0-5])|(7|18)\.([1-9]|1[0-9]|2[0-2])|(8|10|2[01])\.([1-9]|1[0-2])|9\.([1-9]|1[0-4])|12\.([1-9]|[1-9][0-9]|1[0-9][0-9]|20[0-9]|21[0-3])|(13|4[04])\.([1-9]|1[0-1])|14\.([1-9]|[1-3][0-9])|(15|54)\.([1-9]|1[0-9]|20)|(16|42)\.([1-9]|1[0-3])|17\.([1-9]|[1-3][0-9]|4[0-3])|19\.([1-9]|1[0-9]|2[0-1])|22\.([1-9]|[1-9][0-9]|1[0-5][0-9])|(23|30)\.([1-9]|[1-3][0-9]|4[0-6])|24\.([1-9]|[1-8][0-9]|9[0-6])|29\.([1-9]|[1-4][0-9]|50)|31\.([1-9]|[1-9][0-9]|10[0-9]|11[0-2])|32\.([1-9]|[1-4][0-9]|5[0-7])|(3[34])\.([1-9]|[1-4][0-9]|5[0-5])|35\.([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-3][0-9]|24[0-8])|36\.([1-9]|[1-2][0-9]|3[0-1])|37\.([1-9]|[1-2][0-9]|3[0-4])|(3[89])\.([1-9]|1[0-6])|43\.([1-9]|[1-3][0-9]|4[0-4])|45\.([1-9]|[1-9][0-9]|1[0-7][0-9]|180)|46\.([1-9]|[1-9][0-9]|1[0-7][0-9]|18[0-4])|47\.([1-9]|[1-9][0-9]|10[0-4])|48\.([1-9]|[1-9][0-9]|1[0-6][0-9]|17[0-8])|(49|53)\.([1-9]|[1-4][0-9]|5[0-4])|50\.([1-9]|[1-9][0-9]|10[0-8])|51\.([1-9]|[1-7][0-9]|8[0-6])|52\.([1-9]|1[0-9]|2[0-4])|55\.([1-9]|[1-6][0-9]|7[0-4])|56\.([1-9]|[1-9][0-9]|1[0-2][0-9]|13[0-1]))\b

\b(Dhp|DHP|dhp)\s?([1-9]|[1-9][0-9]|[1-3][0-9][0-9]|4[0-1][0-9]|42[0-3])\b

\b(Iti|ITI|iti)\s?([1-9]|[1-9][0-9]|10[0-9]|11[0-2])\b

\b(Snp|SNP|snp)\s?((1|3)\.([1-9]|1[0-2])|2\.([1-9]|1[0-4])|4\.([1-9]|1[0-6])|5\.([1-9]|1[0-9]))\b

\b(Thag|THAG|thag)\s?(1\.([1-9]|[1-9][0-9]|1[0-1][0-9]|120)|2\.([1-9]|[1-4][0-9])|3\.([1-9]|1[0-6])|(4|5)\.([1-9]|1[0-2])|6\.([1-9]|1[0-4])|7\.[1-5]|(8|17)\.[1-3]|(9|1[1389]|2[01])\.1|10\.[1-7]|1[245]\.[1-2]|16\.([1-9]|10))\b

\b(Thig|THIG|thig)\s?(1\.([1-9]|1[0-8])|2\.([1-9]|10)|(3|6)\.[1-8]|([489]|1[0-24-6])\.1|5\.([1-9]|1[0-2])|7\.[1-3]|13\.[1-5])\b

\b(Ud|UD|ud)\s?([1-8]\.([1-9]|10))\b

This should be complete and accurate list of rules now (some tweaks were made and some missing chapters in Thag and Thig were added).

Also, there is an added option to use : as a separator for SN (for legacy purposes).

1 Like