![ConTeXt XML:如何排版空白行、前导空格](https://linux22.com/image/389364/ConTeXt%20XML%EF%BC%9A%E5%A6%82%E4%BD%95%E6%8E%92%E7%89%88%E7%A9%BA%E7%99%BD%E8%A1%8C%E3%80%81%E5%89%8D%E5%AF%BC%E7%A9%BA%E6%A0%BC.png)
我有以下示例,其中一个<Line>
是空白行,另一个有前导空格。ConTeXt 忽略了空白行并修剪了前导空格。我该如何关闭此功能?
\startbuffer[demo]
<?xml version="1.0" encoding="UTF-8"?>
<Reading>
<Header>Foo</Header>
<Line>Line #1</Line>
<Line>Line #2</Line>
<Line></Line>
<Line> Line #3</Line>
</Reading>
\stopbuffer
\startxmlsetups xml:initialize
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{Book|Reading|Header|Line}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:initialize}
\startxmlsetups xml:Reading
\startdocument
\xmlflush{#1}
\stopdocument
\stopxmlsetups
\startxmlsetups xml:Line
\xmlflush{#1}\par
\stopxmlsetups
\xmlprocessbuffer{main}{demo}{}
答案1
使用\xmlflushspacewise
遵守节点内的空格和换行符,并\dontleavehmode
在之前使用,以便连续\par
不会折叠。
\startbuffer[demo]
<?xml version="1.0" encoding="UTF-8"?>
<Reading>
<Header>Foo</Header>
<Line>Line #1</Line>
<Line>Line #2</Line>
<Line></Line>
<Line> Line #3</Line>
</Reading>
\stopbuffer
\startxmlsetups xml:initialize
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{Book|Reading|Header|Line}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:initialize}
\startxmlsetups xml:Reading
\startdocument
\xmlflush{#1}
\stopdocument
\stopxmlsetups
\startxmlsetups xml:Line
\dontleavehmode\xmlflushspacewise{#1}\par
\stopxmlsetups
\xmlprocessbuffer{main}{demo}{}