我有以下示例,其中一个<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}{}