Interpret links (or other AsciiDoc syntax) only in specific lines of a [source] block
Posted by
Oblomov on
Feb 15, 2021; 11:08pm
URL: https://discuss.asciidoctor.org/Interpret-links-or-other-AsciiDoc-syntax-only-in-specific-lines-of-a-source-block-tp8499.html
Hello all,
I've started working on an extension for literate programming with Asciidoctor, called asciidoctor-litprog <
https://github.com/Oblomov/asciidoctor-litprog>. I've got the basics down (mostly) and the extension is “self hosting” (the README is an AsciiDoc document that, when processed with the extension, produces the extension —bootstrap version of the Ruby module is provided for convenience), and I'm now trying to tackle what I believe is the most difficult part of my endeavor (and potentially also one of the least essential, but whatever): “enchancing” the presentation of the source blocks.
The source blocks are standard source blocks, but some lines contain references to other chunks of code. These are completely out of place wrt to the syntax highlighter that applies to the block, and I would like these references (and only them) to be “ignored” by the syntax highlighter, and if possible processed by Asciidoctor to generate hyperlinks to the referenced chunk-defining block(s). However, I'm not sure how I should proceed for that.
My understanding is that I would have to enable some kind of substitution; however, I don't want them applied to the whole block, but only to specific lines (and potentially, in the future, to specific _subsets_ of specific lines). The documentation on how to achieve this programmatically is a bit sparse, so any suggestions on how to do this (or a pointer to the relevant documentation) would be much appreciated.
Thanks in advance,
GB