Skip to content
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

A command-line option to use fenced or indented code blocks only #10290

Open
jsx97 opened this issue Oct 12, 2024 · 0 comments
Open

A command-line option to use fenced or indented code blocks only #10290

jsx97 opened this issue Oct 12, 2024 · 0 comments

Comments

@jsx97
Copy link

jsx97 commented Oct 12, 2024

Currently, if converting from HTML to Markdown, if the document contains code blocks, that is, pre elements, they are converted to fenced code blocks if Pandoc can determine their language and to indented ones otherwise. That is, the output Markdown file may have both fenced and indented code blocks.

It seems to me, however, that fenced-vs-indented-code-blocks thing is a matter of taste. That is, some people prefer indented code blocks and some prefer fenced. And for this reason, it will be absolutely reasonable to provide an option to use only a single style across the whole document. Currently, I use a Lua filter for this, but having a built-in command-line option will be a better solution.

-- https://stackoverflow.com/q/66945893
local fenced = '```\n%s\n```\n'
function CodeBlock (cb)
  if cb.classes[1] or cb.attributes[1] then
    return nil
  end
  return pandoc.RawBlock('markdown', fenced:format(cb.text))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant