3 ms·
Not sure what editor you use, but most syntax highlighters these days can mix languages: you see this e.g. in HTML <style> tags and Markdown fenced code blocks.
by wolfgang42 3y ago
Not sure what editor you use, but most syntax highlighters these days can mix languages: you see this e.g. in HTML <style> tags and Markdown fenced code blocks.
As for 'out of order programming', I think that TANGLE-style reordering is a lot less important with modern programming languages: they don't do one-pass compilation and so can deal with forward references. Note that most of the cross-references in Knuth's program could be replaced with function calls or constant names, rather than the semiautomatic inlining that WEB performs.
I've had some success in writing literate programs in a Markdown file, with a small script to extract the code blocks into a file for execution. This seems to work fine, at least on a small scale, and is very easy to implement and then extend if needed.
Edit: and by “small script” I mean:
import sys
code = False
for line in sys.stdin.read().splitlines():
if line == '```': code = False # End block
if code: print(line) # Only output block contents
if line == '```md': code = True # Start block
It also seems worth noting that you can get much the same result just by writing a lot of comments; this technique is mainly useful when you also want more formatting than can be reasonably squeezed into plain text.
/edit