在 Doxygen 中替代 \f 用于 Latex 公式

Alternative to \f in Doxygen for Latex formulas

在 doxygen 中,如果您希望您的公式格式正确,您必须这样做:

\f$ x=2 \f$

我有很多带有数学公式的 md 文件。这些文件是内部 wiki 的一部分,必须遵守该 wiki 的算法规则。这意味着乳胶格式正常,即 $x=2$.

不过,我还想用 doxygen 补充文档。但是随后生成的数学部分未格式化并显示为纯乳胶代码。

有什么方法可以禁用\f吗?

我能想到的唯一选择是使用脚本将 md 文件复制到临时目录,将 $ 替换为 \f$ 然后指示 doxygen 使用这些文件。这是一种可能性,但却是一种丑陋的可能性。有什么办法可以避免 \f 吗?

您实际上不必复制文件,一种可能是编写一个过滤器,在 doxygen 中为您执行此操作(过滤器将读取文件并将更改后的输出输出到标准输出)。

来自文档 https://www.doxygen.nl/manual/config.html#cfg_filter_patterns):

FILTER_PATTERNS

The FILTER_PATTERNS tag can be used to specify filters on a per file pattern basis. Doxygen will compare the file name with each pattern and apply the filter if there is a match. The filters are a list of the form: pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how filters are used. If the FILTER_PATTERNS tag is empty or if none of the patterns match the file name, INPUT_FILTER is applied.

Note that for custom extensions or not directly supported extensions you also need to set EXTENSION_MAPPING for the extension otherwise the files are not properly processed by doxygen.