This sort of thing can already be done using a filter which replaces Pandoc-specific types with a RawInline and the appropriate markup. For instance, in order to get fenced code blocks, take a CodeBlock and return a RawInline with the initial delimiter, a RawInline with the code and a RawInline with the final delimiter.

Would it be reasonable that the command-line expose the “happy path”, and filters could be used whenever something else is desired?

One drawback is that for arkdown, code blocks consist of unescaped text (mostly, save for the delimiter); but what if the output format requires the text in a code block to be escaped somehow?

 

From: John MacFarlane
Sent: Sunday, 24 January 2021 8:08 pm
To: Allen Downey; pandoc-discuss
Subject: Re: Markdown writer ignores backtick_code_blocks?

 

 

The + notation enables an extension.  That just makes it an

OPTION for the writer.  In this case it doesn't do anything,

since fenced_code_blocks and backtick_code_blocks are

already enabled for markdown by default.

 

Having these enabled tells the writer that it CAN use either

tildes or backticks for a code block (as well as indentation,

which is a core Markdown feature and thus has no extension).

But it doesn't tell it which form to use.  The writer will

prefer indented code blocks when there are no attributes

specified (mainly because it has to choose one form, and

this is the most compatible form).

 

What you'd need would be -indented_code_blocks, but as

I said, that's not an extension because it's a core feature.

 

This issue comes up a lot and there's an issue for it in the

tracker:

https://github.com/jgm/pandoc/issues/5280

 

It would be good to give people more control over the priorities

used for the different syntax possibilities in markdown output,

but I haven't figured out what the best way to do it would be.

In addition to code blocks, similar issues arise for

 

- bullet types (+, -, or *)

- list indentation (4-space or less)?

- headings (setext or atx)

- tables (prefer pipe tables or simple?)

- links (prefer reference or inline?)

 

In the case of headings we have the --markdown-headings option.

For links we have --reference-links (which also affects some

other formats). But I don't know if I want to go down the path of

introducing six more command-line options.

 

 

 

Allen Downey <allendowney-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

 

> Hi All.  I am using pandoc 2.11 with the following test input:

> 

> ```

> Paragraph

> 

> \begin{verbatim}

> Code block

> Code block

> \end{verbatim}

> 

> Paragraph

> ```

> 

> Then I translate to Markdown with the following commands:

> 

> ```

> pandoc test.tex -t markdown > test1.md

> pandoc test.tex -t markdown+fenced_code_blocks > test2.md

> pandoc test.tex -t markdown+backtick_code_blocks > test3.md

> ```

> 

> The result of all three is the same:

> 

> ```

> Paragraph

> 

>     Code block

>     Code block

> 

> Paragraph

> ```

> 

> The code block is indented, which implies that the reader recognizes it as

> a code block.  But the writer seems to ignore the extensions.

> 

> Am I doing something wrong here?

> 

> Thanks!

> Allen

> 

> --

> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.

> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org

> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3001f072-a5fb-450a-9f8c-ba901a31b3c1n%40googlegroups.com.

 

--

You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.

To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org

To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2im7mgqdl.fsf%40MacBook-Pro.hsd1.ca.comcast.net.

 

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/F778D9AE-A228-4D0F-8BEA-1810AFEB668D%40hxcore.ol.