我可以更多地分解在 Markdown 文档顶部创建的标题吗?它有不变的部分,但也有可变的部分

问题描述 投票:0回答:1

我已经这样组织了 Markdown 文档的生成:

export APPRENTISSAGE_HOME=the folder where my documents are

/apprentissage
    gen.sh : a script running a command: 'pandoc -f markdown-implicit_figures 
             --syntax-definition=$APPRENTISSAGE_HOME/java.xml 
             "${source}".md -o "${source}".pdf'
        → gen e020-analyse generates a e020-analyse.pdf from a e020-analyse.md file

    apprentissage-header-include.tex: \usepackage, \DeclareUnicodeCharacter directives
        \usepackage{fvextra}
        \usepackage{mathtools}
        \DeclareUnicodeCharacter{3C3}{\text{$\sigma$}}
        \DisableLigatures[-]{}

    apprentissage-include.tex: definitions of custom commands or colors
        \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,breaksymbol=,breakanywheresymbolpre=,commandchars=\\\{\}}
        \setlength{\abovedisplayskip}{3pt}

        \newcommand{\suspect}[1]{\textbf{\textcolor{gray}{#1}}}
        \newcommand{\fonction}[1]{\begingroup\small\mauve{\texttt{#1}}\endgroup}
        \renewcommand{\abstractname}{Contenu}

        \definecolor{cadreCodeBackground}{RGB}{130,124,106}
        \newcommand{\cadreCode}{\renewtcolorbox{quote}{colback=cadreCodeBackground!5!white,arc=0pt,outer arc=0pt,boxrule=0pt,lowerbox=invisible,code={\tcbset{enlarge left by=0cm}}}}

    /informatique this folder and the next have about 30 markdowns file inside
    /mathematiques
    /statistiques
    /analyse_spatiale
    /territoire

为了工作,我的每个 Markdown 文件都按照下面的方式开始,我想改进

---
---
之间的部分:

---
header-includes:
  \input{$APPRENTISSAGE_HOME/apprentissage-header-include}
  \input{$APPRENTISSAGE_HOME/apprentissage-include}

title: "e020. Analyse textuelle"
subtitle: ""
category: analyse textuelle

keywords:
- TF
- term frequency
- IDF
- inverse difference frequency
- mot
- ponctuation
- token

author: Marc Le Bihan
geometry: margin=1.5cm
fontsize: 12pt
output: pdf
classoption: fleqn
urlcolor: blue
---

Indexation des mots. La qualité de la recherche vient par l'emploi de deux indicateurs :

   - __TF__ (Term Frequency) : fréquence des mots.
[...]

---
分隔符之间的部分,我有两种类型的内容:

  • 对我来说“静态”的:

    author
    geometry
    fontsize
    output
    classoption
    urlcolor

    header-includes:
       \input{$APPRENTISSAGE_HOME/apprentissage-header-include}
       \input{$APPRENTISSAGE_HOME/apprentissage-include}
    

    永远不会改变,位于文件顶部。

  • title
    subtitle
    category
    keywords
    正在逐个文件更改。


我想进一步分解这部分。因为碰巧(无论我说什么)我有时必须更改“静态”部分...然后,要实现这一点很长:所有 Markdown 文件都需要编辑并重新生成其 pdf

  • 我可以在我创建的包含

    author
    文件之一中发送一些关键字
    geometry
    fontsize
    output
    classoption
    urlcolor
    header-includes:
    .tex
    ),以及如何?

  • 或者我应该以某种方式改善我的

    gen.sh
    跑步
    pandoc

  • Latex的另一个功能我还没用过,可以帮助我吗?

latex markdown pandoc
1个回答
0
投票

Markdown 文档的部分选项可以转移到 Pandoc 可以包含的

metadata.json
文件中。

author: Marc Le Bihan
geometry: margin=1.5cm
fontsize: 12pt
classoption: fleqn
urlcolor: blue

元数据.json:

{
  "geometry": "margin=4cm",
  "fontsize": "12pt",
  "classoption": "fleqn",
  "urlcolor": "blue",
  "author": "Marc Le Bihan"
}

Pandoc 生成命令也发生了这样的变化,在里面添加了

--metadata-file

pandoc -f markdown-implicit_figures \
  --syntax-definition=$APPRENTISSAGE_HOME/java.xml \
  --metadata-file=$APPRENTISSAGE_HOME/metadata.json \
  s600-la_fouille_de_données.md -o s600-la_fouille_de_données.pdf
© www.soinside.com 2019 - 2024. All rights reserved.