列表标题内的标记和引用



是否可以在 pandoc 中处理列表标题的文本标记?

Pandoc 适用于图形标题,并翻译了强调inline code,但显然在列出标题时没有这样做。 例如,在下面的代码中,我在第二个列表和图表的标题中有一些格式和引用。 但是,只有图中的格式才能正确转换为乳胶。 列表标题保持原样,这会在管道的后面中断 tex 处理器。

是否可以像处理图表标题一样处理列表标题?


```{#lst:first .C caption="Hi"}
int hi() {
return ((int)'h'<<8) | 'i';
}
```
```{#lst:second .C caption="Code *using* the function `hi` from [@lst:first]"}
x = hi();
```
![Picture *with* `inline code` and reference [@lst:first]](picture.png)

pandoc example.so.md -o example.so.tex --listings --filter=pandoc-crossref

生产:

begin{codelisting}
caption{Hi}
begin{lstlisting}[language=C, caption=Hi, label=lst:first]
int hi() {
return ((int)'h'<<8) | 'i';
}
end{lstlisting}
end{codelisting}
begin{codelisting}
caption{Code *using* the function `hi` from {[}@lst:first{]}}
begin{lstlisting}[language=C, caption={Code *using* the function `hi` from [@lst:first]}, label=lst:second]
x = hi();
end{lstlisting}
end{codelisting}
begin{figure}
centering
includegraphics{picture.png}
caption{Picture emph{with} passthrough{lstinline!inline code!} and
reference lst.~ref{lst:first}}
end{figure}

我使用 pandoc 2.7.3 和 pandoc-crossref v0.3.4.1

附言正如 https://github.com/jgm/pandoc/issues/673 所建议的那样,可能仍然没有原生支持。有解决方法吗?

K4zuki在pandoc google群组上的回应对我有用。https://groups.google.com/forum/#!msg/pandoc-discuss/DItTuL5S1EM/L1Ou25gTCAAJ(

使用此处解释的pandoc-crossref选项:http://lierdakil.github.io/pandoc-crossref/#table-style-captions 在元数据块中添加codeBlockCaptions: true或使用-M codeBlockCaptions=true运行 Pandoc

这奏效了:

Listing: Code *using* the function `hi` from [@lst:first]
```{#lst:second .C}
x = hi();
```

最新更新