uwdata / living-papers

Authoring tools for scholarly communication. Create interactive web pages or formal research papers from markdown source.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature request: output-specific blocks

joshuahhh opened this issue · comments

I'd like to be able to define blocks whose contents render only for a specific output format. Note that this is different from the notation described at https://pandoc.org/MANUAL.html#extension-raw_attribute, because the contents of this block would continue to be Markdown syntax in need of parsing, rather than raw output-specific syntax.

I've partially hacked this in. I use blocks that look like ::: {.html-only}. Then I add special case checks at the top of various output methods. For instance, I put:

if (hasClass(ast, 'html-only')) {
  return undefined;
}

towards the top of tex in tex-format.js.

But this isn't the right place for this check. Really, the first thing the tex-output-specific code should do is go through the AST and prune out these nodes. Problems are caused by delaying this. For instance, the LaTeX image converter goes through the AST to find images to convert. Images inside of ::: {.html-only} blocks should be ignored, but they're not.