Skip to content

Commit

Permalink
Escape MathJax markup in attributes
Browse files Browse the repository at this point in the history
Max Horn noticed that "\[\]" in reference text is interpreted by MathJax
as empty displayed formula.
This text is now escaped by <span> around \.
  • Loading branch information
frankluebeck committed Feb 16, 2022
1 parent 3a78f3a commit 49d76a7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/GAPDoc2HTML.gi
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,11 @@ GAPDoc2HTMLProcs.EscapeAttrVal := function(str)
str := SubstitutionSublist(str, "&", "&amp;");
str := SubstitutionSublist(str, "<", "&lt;");
str := SubstitutionSublist(str, ">", "&gt;");
# for MathJax
str := SubstitutionSublist(str, "\\[", "<span>\\</span>[");
str := SubstitutionSublist(str, "\\]", "<span>\\</span>]");
str := SubstitutionSublist(str, "\\(", "<span>\\</span>(");
str := SubstitutionSublist(str, "\\)", "<span>\\</span>)");
return str;
end;

Expand Down Expand Up @@ -1739,7 +1744,8 @@ GAPDoc2HTMLProcs.Ref := function(r, str)
ref := Concatenation("<a href=\"", ref[6], "\">", rattr[1],
r.attributes.Text, rattr[2], "</a>");
else
ref := Concatenation("<a href=\"", ref[6], "\">", rattr[1], ref[1],
ref := Concatenation("<a href=\"", ref[6], "\">", rattr[1],
GAPDoc2HTMLProcs.EscapeAttrVal(ref[1]),
rattr[2], "</a>");
fi;
elif ref <> fail then
Expand Down

0 comments on commit 49d76a7

Please sign in to comment.