XSL-FO/Apache FOP:启用断字后如何将单词放在一起
XSL-FO/Apache FOP: How to keep a word together when hyphenation is enabled
任务非常简单:防止“donothyphenatethisextremelylongword”在 hyphenate="true"
所在的块内连字符。我尝试了什么:
<root xmlns="http://www.w3.org/1999/XSL/Format" xml:lang="en">
<layout-master-set>
<simple-page-master master-name="the-master-name" page-height="29.7cm"
page-width="21.0cm" margin-top="1.21cm"
margin-bottom=".8cm" margin-left="2.4cm"
margin-right="1.5cm">
<region-body region-name="the-region-body"/>
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="the-master-name">
<flow flow-name="the-region-body">
<block hyphenate="true">
Whereas recognition of the inherent dignity and of the equal and
inalienable rights of all members of the human family is the
foundation of freedom, justice and peace in the world, Whereas
disregard and contempt for human rights have resulted in
barbarous acts which have outraged the conscience of mankind,
and the advent of a
<inline keep-together="always" hyphenate="false" color="red">
donothyphenatethisextremelylongword
</inline>
world in which human beings shall enjoy freedom of speech and
belief and freedom from fear and want has been proclaimed as the
highest aspiration of the common people
</block>
</flow>
</page-sequence>
</root>
结果:
真的没有办法吗?任何帮助将不胜感激。
FWIW,您的示例在 AH Formatter 中运行良好。将单词包装在 fo:inline-container
中并用具有 hyphenate="false"
的 fo:block
包装单词也是如此,但是 FOP 2.6 然后将单词放在单独的行上(因为我认为宽度不是指定)。
我发现唯一适用于 FOP 2.6 的是将 fo:inline
中的每个字符都变成 fo:character
;即 <character character="d" />
,等等
或者,您可以删除 fo:inline
并在每个 fo:character
上重复 hyphenate
:<character hyphenate="false" character="d" />
,等等
您可以删除 keep-together="always"
。没看到有什么效果。
没有必要自己制作 fo:character
。 Section 1.1.2, Formatting, of the XSL 1.1 Recommendation 包括(在图形之后):
As part of the step of objectifying, the characters that occur in the result tree are replaced by fo:character nodes.
我不知道任何格式化程序在实践中会这样做,因为它会激增对象的数量(通常)没有好的效果,但格式化程序应该表现得好像适用于 [=14 的继承属性=] 应用于 运行 文本中的每个字符。
假设段落的宽度已知 before-hand,还有另一个 hacky 解决方法:
<fo:inline-container width="27mm">
<fo:block>mustnotbehyphenated</fo:block>
</fo:inline-container>
这也适用于两端对齐的段落。然而,传递一个固定的 width
是至关重要的。
任务非常简单:防止“donothyphenatethisextremelylongword”在 hyphenate="true"
所在的块内连字符。我尝试了什么:
<root xmlns="http://www.w3.org/1999/XSL/Format" xml:lang="en">
<layout-master-set>
<simple-page-master master-name="the-master-name" page-height="29.7cm"
page-width="21.0cm" margin-top="1.21cm"
margin-bottom=".8cm" margin-left="2.4cm"
margin-right="1.5cm">
<region-body region-name="the-region-body"/>
</simple-page-master>
</layout-master-set>
<page-sequence master-reference="the-master-name">
<flow flow-name="the-region-body">
<block hyphenate="true">
Whereas recognition of the inherent dignity and of the equal and
inalienable rights of all members of the human family is the
foundation of freedom, justice and peace in the world, Whereas
disregard and contempt for human rights have resulted in
barbarous acts which have outraged the conscience of mankind,
and the advent of a
<inline keep-together="always" hyphenate="false" color="red">
donothyphenatethisextremelylongword
</inline>
world in which human beings shall enjoy freedom of speech and
belief and freedom from fear and want has been proclaimed as the
highest aspiration of the common people
</block>
</flow>
</page-sequence>
</root>
结果:
真的没有办法吗?任何帮助将不胜感激。
FWIW,您的示例在 AH Formatter 中运行良好。将单词包装在 fo:inline-container
中并用具有 hyphenate="false"
的 fo:block
包装单词也是如此,但是 FOP 2.6 然后将单词放在单独的行上(因为我认为宽度不是指定)。
我发现唯一适用于 FOP 2.6 的是将 fo:inline
中的每个字符都变成 fo:character
;即 <character character="d" />
,等等
或者,您可以删除 fo:inline
并在每个 fo:character
上重复 hyphenate
:<character hyphenate="false" character="d" />
,等等
您可以删除 keep-together="always"
。没看到有什么效果。
没有必要自己制作 fo:character
。 Section 1.1.2, Formatting, of the XSL 1.1 Recommendation 包括(在图形之后):
As part of the step of objectifying, the characters that occur in the result tree are replaced by fo:character nodes.
我不知道任何格式化程序在实践中会这样做,因为它会激增对象的数量(通常)没有好的效果,但格式化程序应该表现得好像适用于 [=14 的继承属性=] 应用于 运行 文本中的每个字符。
假设段落的宽度已知 before-hand,还有另一个 hacky 解决方法:
<fo:inline-container width="27mm">
<fo:block>mustnotbehyphenated</fo:block>
</fo:inline-container>
这也适用于两端对齐的段落。然而,传递一个固定的 width
是至关重要的。