我需要将源代码示例ConTeXt
与编译结果放在一起。
code:
ConTeXt code example
result:
compiled result
我可以这样做:
\mainlanguage[ru]
\usemodule [simplefonts][size=12pt]
\setmainfont[dejavusans][expansion=quality,protrusion=quality]
\setmonofont[monaco][expansion=quality,protrusion=quality]
\usemodule [vim]
\defineframedtext [CODEBLOCK][background=color,backgroundcolor=lightgray,
width=\dimexpr(\textwidth-1cm),frame=off,offset=2mm]
\definevimtyping[TEX][syntax=context,before=\startCODEBLOCK,after=\stopCODEBLOCK]
\defineframedtext [CODERESULT][width=\textwidth,frame=off,offset=2mm]
\definedescription[descr][indenting=1cm,indentnext=yes,location=right,
width=\textwidth,distance=\dimexpr(1cm-\textwidth),align={width,stretch}]
\starttext
\startdescr{code:} \hfill
\startTEX
\ConTeXt
\stopTEX
\stopdescr
\startdescr{result:} \hfill
\startCODERESULT
\ConTeXt
\stopCODERESULT
\stopdescr
\stoptext
但是代码重复不太方便。
我尝试过这个:
\mainlanguage[ru]
\usemodule [simplefonts][size=12pt]
\setmainfont[dejavusans][expansion=quality,protrusion=quality]
\setmonofont[monaco][expansion=quality,protrusion=quality]
\usemodule [vim]
\defineframedtext [CODEBLOCK][background=color,backgroundcolor=lightgray,
width=\dimexpr(\textwidth-1cm),frame=off,offset=2mm]
\definevimtyping[TEX][syntax=context,before=\startCODEBLOCK,after=\stopCODEBLOCK]
\defineframedtext [CODERESULT][width=\textwidth,frame=off,offset=2mm]
\definedescription[descr][indenting=1cm,indentnext=yes,location=right,
width=\textwidth,distance=\dimexpr(1cm-\textwidth),align={width,stretch}]
\def\texsample#1{
\startdescr{code:} \hfill
\startTEX
#1
\stopTEX
\stopdescr
\startdescr{result:} \hfill
\startCODERESULT
#1
\stopCODERESULT
\stopdescr
}
\starttext
\texsample{
\ConTeXt
}
\stoptext
这是我在启动时看到的ConTeXt
(/usr/share/texmf-dist/tex/context/third/filter/t-filter.mkiv
loading > Filter (ver: 2013.04.15)
resolvers > modules > 'module-catcodes' is loaded
(/usr/share/texmf-dist/tex/context/third/filter/t-module-catcodes.tex
loading > Module Catcodes (ver: 2011.12.17)
))
resolvers > modules > 'syntax-highlight' is loaded
(/usr/share/texmf-dist/tex/context/third/vim/t-syntax-highlight.mkiv
loading > Code syntax highlighting (ver: 2012.08.01)
resolvers > modules > 'syntax-groups' is loaded
(/usr/share/texmf-dist/tex/context/third/vim/t-syntax-groups.tex
loading > Syntax highlighting groups (ver: 2012.05.06)
resolvers > modules > 'module-catcodes' is already loaded
)
resolvers > modules > 'filter' is already loaded
))))
*
什么也没有发生。
答案1
答案2
我能够获得这样的最低必要配置
\startbuffer[comprehensions]
for i, val in #Components
let component = val {
"\(component)": {
extraEnv?: [...corev1.#EnvVar]
resources?: corev1.#ResourceRequirements
tolerations?: [...corev1.#Toleration]
nodeSelector?: [string]: string
}
}
\stopbuffer
\typebuffer[comprehensions][
style={\switchtobodyfont[9pt,tt]},
]