jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.28k stars 3.36k forks source link

Regression: `alerts` extension not working #9824

Closed FeralFlora closed 4 months ago

FeralFlora commented 4 months ago

Explain the problem.

These two commands:

echo "> [!WARNING]" | pandoc -f commonmark -t html
echo "> [!WARNING]" | pandoc -f commonmark+alerts -t html

Produce the same output:

335148288-8fecc8d7-4faa-4c3e-8f83-3cfa6bbede3a

Ergo, alerts does nothing. The HTML output ought to be, as far as I understand:

<div class="warning">
<div class="title">
<p>Warning</p>
</div>
</div>

The same goes for using gfm, where alerts is enabled by default. The output is not as expected:

335146741-cd6ad4e5-16f5-4a70-97ed-f32e5cb209de

Pandoc version? Pandoc version: 3.2 OS: Windows 11

FeralFlora commented 4 months ago

See also: https://github.com/jgm/pandoc/discussions/9821#discussioncomment-9604237

iandol commented 4 months ago

In fact this is working, you need to add whitespace around the tip to trigger the syntax:

echo "\n> [!tip]\n> A Tip\n" | pandoc -f gfm -t html

<div class="tip">
<div class="title">
<p>Tip</p>
</div>
<p>A Tip</p>
</div>
FeralFlora commented 4 months ago

In fact this is working, you need to add whitespace around the tip to trigger the syntax:

echo "\n> [!tip]\n> A Tip\n" | pandoc -f gfm -t html

<div class="tip">
<div class="title">
<p>Tip</p>
</div>
<p>A Tip</p>
</div>

I'm not sure why, but when I copy your command and run it, I get:

<p>"\n&gt; [!tip]\n&gt; A Tip\n"</p>

So I can't reproduce your finding with echo in the command prompt. But it does work when I test it using a proper conversion:

Command:

pandoc "callout-test.md" -f gfm -t html -o "callout-test.html"

Test file:

# Testing callouts

> [!tip]
> A Tip

Output:

<h1 id="testing-callouts">Testing callouts</h1>
<div class="tip">
<div class="title">
<p>Tip</p>
</div>
<p>A Tip</p>
</div>

So either the issue can be closed, or perhaps reframed?

iandol commented 4 months ago

I think your terminal is rewriting the < and > characters? If you type into stdin directly (use CTRL+D to exit this mode), then you should be able to type in the syntax and get a response out?

jgm commented 4 months ago

I think you may need to use single quotes with echo here, because > and ! have special meaning in the shell. Anyway, this works fine as you can see from Try Pandoc: https://pandoc.org/try/?params=%7B%22text%22%3A%22%3E+%5B%21WARNING%5D%5Cn%22%2C%22to%22%3A%22html5%22%2C%22from%22%3A%22gfm%22%2C%22standalone%22%3Afalse%2C%22embed-resources%22%3Afalse%2C%22table-of-contents%22%3Afalse%2C%22number-sections%22%3Afalse%2C%22citeproc%22%3Afalse%2C%22html-math-method%22%3A%22plain%22%2C%22wrap%22%3A%22auto%22%2C%22highlight-style%22%3Anull%2C%22files%22%3A%7B%7D%2C%22template%22%3Anull%7D

FeralFlora commented 4 months ago

I think you may need to use single quotes with echo here, because > and ! have special meaning in the shell. Anyway, this works fine as you can see from Try Pandoc

Yeah, sorry for jumping the gun on this.

I tried with single quotes, but that doesn't echo anything: WindowsTerminal_xKeKXjAKu3

But anyway, since it works with proper conversions (not echo), this is some other issue of my own.