-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source map for code blocks #4657
Comments
I can see the use of this. It might make more sense to develop it as a markdown extension, so you'd do Adding source attributes to everything is impossible, since only a few things currently have attributes. Adding just to code blocks seems a bit ad hoc -- it's useful for you, but how generally useful is it? So I'm not sure what to think about this. (Of course, I wish I'd designed for source position information from the beginning, and I am doing that in the brand new markdown parsing library I'm working on, commonmark-hs.) |
I thought about doing it as an extension, but the file which has extensions seemed to indicate that that extensions are specifically for syntactic changes in the source, and this does not change the Markdown syntax, just the data collected at parse time. I don't really mind implementing it either way. I could be persuaded about adding this to more In terms of general usefulness, I guess I've been thinking of I also have a patched version of Pandoc which adds "code-writers" directly, so that you can do I think I agree that the "correct" way to do it is to have every node of the |
This would be very useful, even if only The one additional thing that would be helpful for my case is source information for inline |
@gpoore have you seen Panpipe? https://hackage.haskell.org/package/panpipe |
@ehildenb No, I hadn't seen that. Thanks! I think what I'm working on is more general. I want the option to have, say, all Python code blocks and inline code executed within a single Python session, so that all variables and data are shared. I've done something similar in the past in LaTeX with PythonTeX, and now want something similar that's based on markdown. I'm also hoping to have optional support for Jupyter kernels to manage the execution. |
It would be like the Maybe for now adding a |
Ok, I will do it like that. |
btw, this issue is a subset of #4565, right? |
If #4565 was a PR and not an issue, I would agree (though maybe there is an associated PR, see #4659 ). It looks promising though, so maybe a bit more discussion. But I don't think we should halt progress to find the perfect solution for this, incremental approaches seem better. Will continue discussion over there. |
I found this discussion on pandoc-discuss: https://groups.google.com/forum/#!searchin/pandoc-discuss/source$20line$20numbers$20for$20code%7Csort:date/pandoc-discuss/pDs41Da4KjA/SKt35OWyhxAJ
Did anything ever become of it? We use
pandoc
for literate programming in the K language without having to write a literate programming language (Markdown sources, generate K files). See examples at https://github.com/kframework/evm-semantics.Currently we use
pandoc-tangle
, a filter at https://github.com/ehildenb/pandoc-tangle, for selecting code blocks to be included in each resulting K file (basicallypandoc-tangle
is aWriter
for code). For each other line of input, blank lines are generated to make the target K files have the same line numbers as the source markdown. This is a bit fragile, and assumes that people write "sane-ish" markdown.A better solution would be to have access to the source information of each
CodeBlock
as attributes. I have a patch which adds source attributes toCodeBlock
s in the Markdown reader, along with a command-line flag--insert-source-attrs
and reader optionreaderInsertSourceAttr
. I'm working on tests, let me know if this has a chance getting merged, or if a different approach should be taken.I've thought about whether it makes sense to add these source attributes for all
Block
which containAttr
, and would be willing to do that as well, though I don't think it will be useful for literate programming using Markdown.The text was updated successfully, but these errors were encountered: