fletcher / MultiMarkdown-6

Lightweight markup processor to produce HTML, LaTeX, and more.
https://fletcher.github.io/MultiMarkdown-6/
Other
630 stars 90 forks source link

Referencable codeblocks #126

Open tux-mind opened 6 years ago

tux-mind commented 6 years ago

Hi, first of all, thank you for this project, it is a great tool to save precious time.

I would like to ask a new feature: referencable fenced code blocks.

When a fenced code block is translated into latex, it has neither a caption nor a label.

I solved this by using this hack, which includes those two latex parameters into the lstlisting command arguments:

\```Ruby,label={such_code},caption={Very\,listing}
puts("WOW")
\```

backslash are needed to escape GitHub markdown fenced code blocks. \, inserts a space in latex, as whitespace would stop the parsing of the code language

You can reference the code using [](#such_code).

I hope that this helps, best regards, tux_mind.

fletcher commented 6 years ago

I'll have to think about this one. I'm not sure it directly translates into HTML, and I worry about overloading the fenced code block syntax too much.

I'll leave this open for anyone else to comment if they choose.