Re:Show HN: CodeLink: create links to blocks of code in your...
by MilStdJunkie on Tuesday November 22, 2022 @06:11PM
(#33712870)
I do something like this with Asciidoc's include directive, but including to a tagged region in the source, with the tags in a block comment. The include lives in a code block, so it gets formatted right.
[ Parent
| on HN ]
Re:Show HN: CodeLink: create links to blocks of code in your...
by rupertdenton on Tuesday November 22, 2022 @06:33PM
(#33713073)
That's really interesting. How do you find using that process? I haven't seen it in action.
Re:Show HN: CodeLink: create links to blocks of code in your...
by MilStdJunkie on Tuesday November 29, 2022 @02:48PM
(#33792314)
Sorry for the delay! I made up an example in Python. See also https://docs.asciidoctor.org/asciidoc/latest/directives/incl...
Asciidoc document:
// Asciidoc begins
= Test include to code
Here's a paragraph. Let's take a look at a code block plus an include
[source, python]
----
include::loops.py[tag=count]
----
Python code filename loops.py # Python begins
# // tag::count[]
count = 0
# // end::count[]
while count < 5:
print(count)
count += 1 # This is the same as count = count + 1
Output (text) - this is formatted in HTML or PDF as title, para, then a code block Test include to code
Here’s a paragraph. Let’s take a look at a code block plus an include
count = 0