Item1757: MathModePlugin produces multi-line img tags

pencil
Priority: Normal
Current State: Closed
Released In:
Target Release: n/a
Applies To: Extension
Component: MathModePlugin
Branches:
Reported By: MichaelTempest
Waiting For:
Last Change By: MichaelTempest
MathModePlugin can produce img tags that span lines, and these are not always rendered as images. Instead, the < and > are converted to &lt; and &gt; and so the browser shows the img tag code.

For example, this example taken from MathModePlugin:
<latex title="Calligraphics" color="orange">
  \cal
  A, B, C, D, E, F, G, H, I, J, K, L, M, \\
  \cal
  N, O, P, Q, R, S, T, U, V, W, X, Y, Z
</latex>
... produces this HTML:
&lt;img alt="\cal
  A, B, C, D, E, F, G, H, I, J, K, L, M, \  \cal
  N, O, P, Q, R, S, T, U, V, W, X, Y, Z" class="mmpImage" src="/fw/pub/System/MathModePlugin/_MathModePlugin_2a610dcb31a93be293067cf1a48e8c4e.png" title="Calligraphics" color="orange" size="Large" /&gt;

Foswiki does not, in general, handle img tags that span multiple lines. MathModePlugin strips leading whitespace and trailing whitespace, and it appears that foswiki removes backslash-newline sequences from the alt attribute, and I think that is why this example (also from MathModePlugin) works:
<latex>
  {\cal P} & = & \{f_1, f_2, \ldots, f_m\} \\
  {\cal C} & = & \{c_1, c_2, \ldots, c_m\} \\
  {\cal N} & = & \{n_1, n_2, \ldots, n_m\}
</latex>
... producing this HTML:
<img alt="{\cal P} &#38; &#61; &#38; \{f&#95;1, f&#95;2, \ldots, f&#95;m\} \  {\cal C} &#38; &#61; &#38; \{c&#95;1, c&#95;2, \ldots, c&#95;m\} \  {\cal N} &#38; &#61; &#38; \{n&#95;1, n&#95;2, \ldots, n&#95;m\}" class="mmpImage" src="/fw/pub/System/MathModePlugin/_MathModePlugin_350ce2adb8eb45bb05ff77b5f45cf15d.png"  />

I can fix the problem by changing this in entityEncode() in lib/Foswiki/Plugins/MathModePlugin/Core.pm
    s/([[\x01-\x09\x0b\x0c\x0e-\x1f"%&'*<=>@[_\|$extra])/'&#'.ord($1).';'/ge;
to
    s/([[\x01-\x1f"%&'*<=>@[_\|$extra])/'&#'.ord($1).';'/ge;
(see http://trac.foswiki.org/browser/trunk/MathModePlugin/lib/Foswiki/Plugins/MathModePlugin/Core.pm?rev=3649#L226 for context).

-- MichaelTempest - 20 Jun 2009

Michael, tested your fix. Works perfectly. Would you like to check it in?

-- MichaelDaum - 24 Jun 2009

Will do.

-- MichaelTempest - 24 Jun 2009

Done. Task closed.

-- MichaelTempest - 24 Jun 2009

ItemTemplate edit

Summary MathModePlugin produces multi-line img tags
ReportedBy MichaelTempest
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component MathModePlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins MathModePlugin:f2982da0104b
TargetRelease n/a
ReleasedIn
Topic revision: r6 - 24 Jun 2009, MichaelTempest
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy