Stange footnote URL line wrap

10 views
Skip to first unread message

Vladimir Kulev

unread,
Dec 14, 2012, 5:32:47 AM12/14/12
to wikipu...@googlegroups.com
Hi!

Long footnote URL is misplaced, while normal footnote is not. Do you know how to fix it?

JR

unread,
Dec 15, 2012, 7:22:55 PM12/15/12
to wikipu...@googlegroups.com
Hi,

The cause is text justification -- the footnote consists of <number><space><url-chars><discretionary-hyphenation-char> ...

The typesetting engine finds where to split the url on a discretionary hyphenation character, then stretches the <space> character to justify the first line.

The alternative would be to set url footnotes "ragged right" which would yield a footnote with white space at the end of the line. Would that be a better option?

In this particular example, the result may be improved if we can find a way to treat "&amp;" as a discretionary hyphenation character.

JR

Vladimir Kulev

unread,
Dec 17, 2012, 10:47:30 AM12/17/12
to wikipu...@googlegroups.com
Hi,

After these changes it feels better for me:

 <xsl:template match="url">
   <xsl:variable name="url" select="normalize-space(@name)" />
+  <xsl:if test="parent::footnote">
+      <xsl:text>\raggedright</xsl:text>
+  </xsl:if>


   $txt = preg_replace('/(?:([-.,@#%=_\\/?])(.))|(?:(:)([^\\/]))/',
                       '<tbook:discy kind="$1$3"/>$2$4', $txt);
+  $txt = preg_replace('/(&amp;)(.)/',
+                      '<tbook:discy kind="\\\\$1"/>$2', $txt);

JR

unread,
Dec 18, 2012, 12:07:50 AM12/18/12
to wikipu...@googlegroups.com
I have implemented this slightly differently and perhaps more robustly.

1. ragged right

<xsl:template match="footnote">

  ...

+  <xsl:if test="child::url">
+    <xsl:text>\raggedright </xsl:text>
+  </xsl:if>
  <xsl:apply-templates/>

Otherwise, in the edge case where <footnote> contains two or more <url> tags, the xsl will insert multiple \raggedright commands.

2. &amp;

<xsl:template match="discy">
  <xsl:text>\discy{</xsl:text>
-  <xsl:if test="'_' = @kind or '%' = @kind or '#' = @kind">
+  <xsl:if test="'_' = @kind or '%' = @kind or '#' = @kind or '&amp;' = @kind">

and:

+  $txt = preg_replace('/(&amp;)(.)/',
+                      '<tbook:discy kind="$1"/>$2', $txt);

This is because \& is latex-specific coding, so belongs with wikibook to latex transform. If, for example, we transform wikibook xml to docbook, then \& would be incorrect.

I'll include these changes in the next release. See http://www.wikipublisher.org/wiki/Main/WikiSandbox

Thanks!

JR
Reply all
Reply to author
Forward
0 new messages