Mercurial > octave
changeset 22306:2cd1afd0f12f
publish.m: prevent formatting of inline and block math.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Tue, 16 Aug 2016 16:23:00 +0200 |
parents | 510886d03ef2 |
children | 3732bee69510 |
files | scripts/general/publish.m |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/publish.m Tue Aug 16 02:07:58 2016 +0100 +++ b/scripts/general/publish.m Tue Aug 16 16:23:00 2016 +0200 @@ -812,6 +812,12 @@ str = regexprep (str, '<(\S{3,}[^\s<>]*) *([^<>$]*)>', ... formatter ("link", "$1", "$2")); oldstr = str; + ## Save inline "$" and block "$$" LaTeX math + [~,~,~,math_cstr] = regexp (str, '\${1,2}.*?\${1,2}'); + for i = 1:length(math_cstr) + str = regexprep (str, '\${1,2}(.*?)\${1,2}', ... + ["PUBLISHMATH", num2str(i)], "once"); + endfor ## Loop because of inlined expressions, e.g. *BOLD _ITALIC_* do oldstr = str; @@ -822,6 +828,10 @@ ## Monospaced str = regexprep (str, '\|([^|$_*]*)\|', formatter ("monospaced", "$1")); until (strcmp (str, oldstr)) + ## Restore inline "$" and block "$$" LaTeX math + for i = 1:length(math_cstr) + str = strrep (str, ["PUBLISHMATH", num2str(i)], math_cstr{i}); + endfor ## Replace special symbols str = strrep (str, "(TM)", formatter("TM")); str = strrep (str, "(R)", formatter("R"));