我正在尝试使用 Context,希望能够用 Markdown 编写,但使用 Context 进行编译。我发现了这个教程描述了这样的工作流程,但是运行时出现以下错误context --environment=ENVMD --mode=standalone test.md
:
tex error > tex error on line 3 in file /Users/xxx/Desktop/context/test.md: ! You can't use `macro parameter character #' in vertical mode
我的 test.md 文件包含:
# This is a heading
## This is a sub heading
- list 1
- list 2
- list 3
## This is another sub-heading
我的 ENVMD.tex 文件包含:
% file ENVMD.tex
\startenvironment ENVMD
% Setups for fonts, layout, and styles
\usemodule[filter]
\defineexternalfilter
[markdown]
[filtercommand={pandoc -f \externalfilterparameter{format} -t context
-i \externalfilterinputfile\space
-o \externalfilteroutputfile},
format=markdown,
directory=output]
\stopenvironment
\doifnotmode{standalone}{\endinput}
\starttext
\processmarkdownfile{\inputfilename}
\stoptext
有谁知道为什么这不起作用或者知道更好的工作流程?
更新 1:
按照@Aditya 的建议删除 \startenvironment 和 \stopenvironment 后,输出如下所示:
1
markdown[title=This is a heading]
1.1
markdown[title=This is a sub heading]
更新 2:
test.tex文件的内容为:
\section[this-is-a-heading]{This is a heading}
\subsection[this-is-a-sub-heading]{This is a sub heading}
\startitemize[packed]
\item
list 1
\item
list 2
\item
list 3
\stopitemize
\subsection[this-is-another-sub-heading]{This is another sub-heading}
答案1
该命令在必须加载的模块\processmarkdownfile
中定义。markdown
\usemodule[markdown]
\startbuffer[markdown]
# This is a heading
## This is a sub heading
- list 1
- list 2
- list 3
## This is another sub-heading
1. list 1
2. list 2
3. list 3
\stopbuffer
\savebuffer[list=markdown,prefix=no,file=test.md]
\usemodule[markdown]
\starttext
\processmarkdownfile{test.md}
\stoptext