mar*_*t1n 10 html markdown pandoc
因此代码块可以使用fenced_code_blocks扩展名定义HTML属性:
~~~~ {#mycode .haskell .numberLines startFrom="100"}
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
qsort (filter (>= x) xs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
是否可以以某种方式对常规文本块使用上述语法?例如,我想转换以下Markdown文字:
# My header
~~~ {.text}
This is regular text. This is regular text.
~~~
~~~ {.quote}
> This is the first level of quoting.
>
> > This is nested blockquote.
>
> Back to the first level.
~~~
~~~ {data-id=test-123}
+ Red
+ Green
+ Blue
~~~
Run Code Online (Sandbox Code Playgroud)
进入这样的事情:
<h1 id="my-header">My header</h1>
<p class="text">This is regular text. This is regular text.</p>
<blockquote class="quote">
<p>This is the first level of quoting.</p>
<blockquote>
<p>This is nested blockquote.</p>
</blockquote>
<p>Back to the first level.</p>
</blockquote>
<ul data-id="test-123">
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
如果Pandoc本身没有这样的支持,是否可以在Lua中创建一个自定义编写器呢?
编辑:看看sample.lua自定义编写器,任何人都知道第35行的"属性表"是什么?如何将这些属性传递给特定的Pandoc元素?此外,我正在寻找的功能非常类似于header_extension扩展,除了它适用于所有元素,而不仅仅是标题.
这在kramdown中非常可行,它将转换以下输入
# My header
This is regular text. This is regular text.
{: .text}
> This is the first level of quoting.
>
> > This is nested blockquote.
>
> Back to the first level.
{: .quote}
+ Red
+ Green
+ Blue
{: data-id="test-123"}
Run Code Online (Sandbox Code Playgroud)
到
<h1 id="my-header">My header</h1>
<p class="text">This is regular text. This is regular text.</p>
<blockquote class="quote">
<p>This is the first level of quoting.</p>
<blockquote>
<p>This is nested blockquote.</p>
</blockquote>
<p>Back to the first level.</p>
</blockquote>
<ul data-id="test-123">
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅语法的属性列表定义部分。