jgm/pandoc

`RawBlock` and `raw_attributes` does not always respect the FORMAT or `--to` value

Open

#8,880 建立於 2023年5月30日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)Haskell (44,133 star) (3,850 fork)batch import
buggood first issue

描述

From documentation, pandoc.RawBlock and raw_attributes are supposed to respect the FORMAT or --to value

  • For raw_attributes, doc says https://pandoc.org/MANUAL.html#extension-raw_attribute

    The format name should match the target format name (see -t/—to, above, for a list, or use pandoc —list-output-formats)

  • For pandoc.RawBlock only says format of content without much precision.

I would think that pandoc.RawBlock(FORMAT, text) would work, but FORMAT is

The global FORMAT is set to the format of the pandoc writer being used (html5, latex, etc.), so the behavior of a filter can be made conditional on the eventual output format.

but it seems this don’t work in some case like revealjs

```{=revealjs}
content
```

does not get included in output, only using html works. Same with pandoc.RawBlock()

I believe other format like epub will be the same.

It seems for some format there is a matching done, like with beamer for latex format https://github.com/jgm/pandoc/blob/0e0c00db5159c6edad01b95a5b3047315fb40780/src/Text/Pandoc/Writers/LaTeX.hs#L467-L474

but for other like in HTML, only html will be recognized for RawBlock https://github.com/jgm/pandoc/blob/0e0c00db5159c6edad01b95a5b3047315fb40780/src/Text/Pandoc/Writers/HTML.hs#L908-L920

https://github.com/jgm/pandoc/blob/0e0c00db5159c6edad01b95a5b3047315fb40780/src/Text/Pandoc/Writers/HTML.hs#L1737-L1741

Probably all the slides format should be added in there ?

Though it seems epub also has this issue https://github.com/jgm/pandoc/blob/0e0c00db5159c6edad01b95a5b3047315fb40780/src/Text/Pandoc/Writers/EPUB.hs#L1166-L1170 https://github.com/jgm/pandoc/blob/0e0c00db5159c6edad01b95a5b3047315fb40780/src/Text/Pandoc/Writers/EPUB.hs#L1157-L1161

as epub won't be recognized as a valid rawBlock format.

Hopefully this is clear enough. I can show more example.

I would expect --to format to work in ```{=format} syntax, and also pandoc.RawBlock(FORMAT, ...) to work too.

Originally posted in https://groups.google.com/g/pandoc-discuss/c/2ffxC1uLh2M

貢獻者指南