代码之家  ›  专栏  ›  技术社区  ›  Stefan Jung

去除FOP内联元素中的空白

  •  1
  • Stefan Jung  · 技术社区  · 9 年前

    使用DITA-OT PDF2在FOP中剥离内联元素内部的空白失败。这是我的代码片段:

    <p>1 BEFORE <uicontrol>test</uicontrol> AFTER</p>
    <p>2 BEFORE <uicontrol> test</uicontrol> AFTER</p>
    <p>3 BEFORE <uicontrol>test </uicontrol> AFTER</p>
    <p>4 BEFORE <uicontrol><keyword keyref="test"/> </uicontrol> AFTER</p>
    <p>5 BEFORE <uicontrol> <keyword keyref="test"/></uicontrol> AFTER</p>
    <p>6 BEFORE <uicontrol>
      <keyword keyref="test"/>
    </uicontrol> AFTER</p>
    <p>7 BEFORE <uicontrol>  
      <keyword keyref="test"/>
    </uicontrol> AFTER</p>
    

    呈现给:

    这是我的属性集:

    <xsl:attribute-set name="uicontrol">
        <xsl:attribute name="white-space">nowrap</xsl:attribute>
        <xsl:attribute name="white-space-treatment">ignore</xsl:attribute>
        <xsl:attribute name="white-space-collapse">true</xsl:attribute>
        <xsl:attribute name="linefeed-treatment">treat-as-zero-width-space</xsl:attribute>
        <xsl:attribute name="background-color">#ff0000</xsl:attribute>
    </xsl:attribute-set>
    

    必须去除所有红色空白。我的错误在哪里?

    1 回复  |  直到 9 年前
        1
  •  1
  •   Toshihiko Makita    9 年前

    XSL-FO Property Support Table (§7)

    因此可能需要使用<xsl:strip-space-elements=“uicontrol”>加上用于uicontrol中文本()的normalize-space()函数。

    以下是指定<xsl:strip-space-elements=“uicontrol”>

    After applying xsl:strip-space

    为了您的参考,天线之家渲染原始样式定义如下:

    AHF render result

    希望这有助于您的发展。

    推荐文章