From c7ce214f8c3ae4d250e2d555e26084f3393e05ea Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 15 May 2019 13:30:20 +0100 Subject: [PATCH] Merge pull request #1770 from overleaf/ns-tags-and-tikz handle math in \tag* and \tikz commands GitOrigin-RevId: 6a71100409f405d58e04d12403acd3f4f24360c7 --- .../web/public/js/ace-1.4.3/worker-latex.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/services/web/public/js/ace-1.4.3/worker-latex.js b/services/web/public/js/ace-1.4.3/worker-latex.js index a40e7dc5e0..abe246ca37 100644 --- a/services/web/public/js/ace-1.4.3/worker-latex.js +++ b/services/web/public/js/ace-1.4.3/worker-latex.js @@ -1690,6 +1690,21 @@ var readOptionalGeneric = function(TokeniseResult, k) { return null; }; +var readOptionalStar = function(TokeniseResult, k) { + var Tokens = TokeniseResult.tokens; + var text = TokeniseResult.text; + + var params = Tokens[k + 1]; + + if (params && params[1] === "Text") { + var paramNum = text.substring(params[2], params[3]); + if (paramNum.match(/^(\*)+\s*$/)) { + return k + 1; // got it + } + } + return null; +}; + var readOptionalDef = function (TokeniseResult, k) { var Tokens = TokeniseResult.tokens; var text = TokeniseResult.text; @@ -1947,9 +1962,13 @@ var InterpretTokens = function (TokeniseResult, ErrorReporter) { } else if (seq === "input") { newPos = read1filename(TokeniseResult, i); if (newPos === null) { continue; } else {i = newPos;}; - } else if (seq === "hbox" || seq === "text" || seq === "mbox" || seq === "footnote" || seq === "intertext" || seq === "shortintertext" || seq === "textnormal" || seq === "tag" || seq === "reflectbox" || seq === "textrm") { + } else if (seq === "hbox" || seq === "text" || seq === "mbox" || seq === "footnote" || seq === "intertext" || seq === "shortintertext" || seq === "textnormal" || seq === "reflectbox" || seq === "textrm") { nextGroupMathMode = false; - } else if (seq === "rotatebox" || seq === "scalebox" || seq == "feynmandiagram") { + } else if (seq === "tag") { + newPos = readOptionalStar(TokeniseResult, i); + if (newPos === null) { /* do nothing */ } else {i = newPos;}; + nextGroupMathMode = false; + } else if (seq === "rotatebox" || seq === "scalebox" || seq == "feynmandiagram" || seq === "tikz") { newPos = readOptionalGeneric(TokeniseResult, i); if (newPos === null) { /* do nothing */ } else {i = newPos;}; newPos = readDefinition(TokeniseResult, i);