-
-
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
Add caption option for code blocks #673
Comments
Looking at what (for instance) docbook expects, a better way is to have a figure wrap a code block, i.e. like the following non-working code: ![This is the caption](
) |
If you using fenced code blocks it is possible to add attributes to the code block:
If you compile to latex this gets correct shown in the output (at least if you compile with
If you compile to html the
But this is more like a hack and not a solution. |
You could add a little javascript to make these captions appear in HTML; perhaps it can also be done with pure CSS? |
Good catch! Yes you can even do it with css:
But another thing: caption attribute is no valid html. What do you think of prefixing all attributes with |
Sorry to revisit this. My main "complaint" isn't so much that it is impossible to use a caption, but that the caption technique differs so much from the one in use for tables. |
I have the same issue - the use of caption causes epub verification to fail. |
EPUB contents must be valid xhtml. Try using "data-caption" instead +++ James Turnbull [Jul 17 14 08:04 ]:
|
If I specify data-caption inside a fenced code block I get: 00-frontsmatter.tex:297: Package xkeyval Error: When I try to build to PDF. I am trying to build to PDF and ePub for the project. I guess I can sed it before I build the ePub. |
I like the proposal for the markup syntax. For the rendering, I think (i) either the HTML writer should special-case check for this attribute, and and convert it to |
Images and Tables can have captions as well and captions can contain markup (in contrast to the suggested solution with attributes). I'd prefer the common syntax of tables captions:
My current workaround is to filter code blocks followed by paragraphs that start with
As far as I tried is it not possible to create such 1x1 multiline table with inner code block in Markdown syntax. |
Can we agree that extending table caption syntax to code blocks is probably best idea so far? For LaTeX output, we can probably leverage Thoughts? |
From the HTML specification:
Can we have
Note: this approach will be more similar with
|
I think it should be as universal as possible—I just encountered the problem needing to caption a mathematical formula (display math, as in |
@lierdakil: Using float seems like a good idea, this could easily work for the others, too! (Like for my formula) |
Did you try LaTeX Caption for mathematical formulas works in a very different way that
instead of
and
Moreover, |
Ever any updates on this? |
@aparcar You can use something like the syntax proposed by @rgaiacs, then write a pandoc filter... |
Or, you know, there's support for listings in pandoc-crossref. Which may or may not suit your particular use-case. |
I just proposed a unified way to define |
It would be nice to have some way to specify a caption for code blocks in the style of the table caption.
codeline1
codeline2
codeline3
Code: caption explaning the code above
The text was updated successfully, but these errors were encountered: