From 08bf3696e7fd94c82c9da339de1a30ad72344e43 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Sun, 10 Aug 2014 00:02:33 +0000 Subject: [PATCH 01/16] some more syntax highlighting for latex mode --- lib/ace/mode/latex_highlight_rules.js | 46 +++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 3057c0de..43ee0394 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -4,11 +4,22 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var LatexHighlightRules = function() { +var LatexHighlightRules = function() { + this.$rules = { "start" : [{ - // A tex command e.g. \foo token : "keyword", + regex : "\\\\(documentclass|usepackage|label)" + },{ + token : "constant.character.escape", + regex : "\\\\{2}" + },{ + token : "storage.type", + regex : "\\\\(:?begin|end)", + next : "block" + },{ + // A tex command e.g. \foo + token : "storage.type", regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" }, { // Curly and square braces @@ -18,19 +29,40 @@ var LatexHighlightRules = function() { // Curly and square braces token : "rparen", regex : "[\\])}]" - }, { - // Inline math between two $ symbols - token : "string", - regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$" }, { // A comment. Tex comments start with % and go to // the end of the line token : "comment", regex : "%.*$" + },{ + // An equation + token : "string", + regex : "\\${1,2}", + next : "equation" + }], + "block" : [{ + token : ["","variable.parameter",""], + regex : "({)([^}\\s]*)(}?)", + next : "start" + },{ + token : "", + regex : "", + next : "start" + }], + "equation" : [{ + token : "string", + regex : "\\${1,2}", + next : "start" + },{ + token : "constant.character.escape", + regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" + },{ + token : "string", + regex : "." }] + }; }; - oop.inherits(LatexHighlightRules, TextHighlightRules); exports.LatexHighlightRules = LatexHighlightRules; From b8f135a37d1c85eba1d48aba087d86d28d10b063 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Sun, 10 Aug 2014 00:29:39 +0000 Subject: [PATCH 02/16] adjustments to latex mode --- lib/ace/mode/latex_highlight_rules.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 43ee0394..fe3ff646 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -11,16 +11,18 @@ var LatexHighlightRules = function() { token : "keyword", regex : "\\\\(documentclass|usepackage|label)" },{ + // Escaped character (including new line) token : "constant.character.escape", - regex : "\\\\{2}" + regex : "\\\\[^a-zA-Z]" },{ + // A block token : "storage.type", regex : "\\\\(:?begin|end)", next : "block" },{ // A tex command e.g. \foo token : "storage.type", - regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" + regex : "\\\\[a-zA-Z\\d]+" }, { // Curly and square braces token : "lparen", From d029129b280915893b2a487925f93177145742e5 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Sun, 10 Aug 2014 01:17:39 +0000 Subject: [PATCH 03/16] lparen, rparen in block --- lib/ace/mode/latex_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index fe3ff646..19d7e83a 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -43,7 +43,7 @@ var LatexHighlightRules = function() { next : "equation" }], "block" : [{ - token : ["","variable.parameter",""], + token : ["lparen","variable.parameter","rparen"], regex : "({)([^}\\s]*)(}?)", next : "start" },{ From b5560a9cad8c80e4a45e78414e6f96ac90e46b43 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Sun, 10 Aug 2014 01:18:28 +0000 Subject: [PATCH 04/16] adjust tests --- lib/ace/mode/_test/tokens_latex.json | 72 +++++++++++++++------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/ace/mode/_test/tokens_latex.json b/lib/ace/mode/_test/tokens_latex.json index 0ac37725..77bd5f1a 100644 --- a/lib/ace/mode/_test/tokens_latex.json +++ b/lib/ace/mode/_test/tokens_latex.json @@ -6,33 +6,35 @@ ["rparen","}"] ],[ "start", - ["keyword","\\title"], + ["storage.type","\\title"], ["lparen","{"], - ["keyword","\\LaTeX"], + ["storage.type","\\LaTeX"], ["rparen","}"] ],[ "start", - ["keyword","\\date"], + ["storage.type","\\date"], ["lparen","{"], ["rparen","}"] ],[ "start", - ["keyword","\\begin"], - ["lparen","{"], - ["text","document"], + ["storage.type","\\begin"], + ["lparen","{"] +],[ + "block", + ["variable.parameter","document"], ["rparen","}"] ],[ "start", ["text"," "], - ["keyword","\\maketitle"] + ["storage.type","\\maketitle"] ],[ "start", ["text"," "], - ["keyword","\\LaTeX"], + ["storage.type","\\LaTeX"], ["lparen","{"], ["rparen","}"], ["text"," is a document preparation system for the "], - ["keyword","\\TeX"], + ["storage.type","\\TeX"], ["lparen","{"], ["rparen","}"] ],[ @@ -50,26 +52,26 @@ ],[ "start", ["text"," and much more. "], - ["keyword","\\LaTeX"], + ["storage.type","\\LaTeX"], ["lparen","{"], ["rparen","}"], ["text"," was originally written in 1984 by Leslie"] ],[ "start", ["text"," Lamport and has become the dominant method for using "], - ["keyword","\\TeX"], + ["storage.type","\\TeX"], ["text","; few"] ],[ "start", ["text"," people write in plain "], - ["keyword","\\TeX"], + ["storage.type","\\TeX"], ["lparen","{"], ["rparen","}"], ["text"," anymore. The current version is"] ],[ "start", ["text"," "], - ["keyword","\\LaTeXe"], + ["storage.type","\\LaTeXe"], ["text","."] ],[ "start", @@ -85,43 +87,49 @@ ],[ "start", ["text"," "], - ["keyword","\\begin"], - ["lparen","{"], - ["text","align"], + ["storage.type","\\begin"], + ["lparen","{"] +],[ + "block", + ["variable.parameter","align"], ["rparen","}"] ],[ "start", ["text"," E &= mc^2 "], - ["keyword","\\\\"] + ["constant.character.escape","\\\\"] ],[ - "start", - ["text"," m &= "], - ["keyword","\\frac"], + "equation", + ["string"," m &= "], + ["constant.character.escape","\\frac"], ["lparen","{"], - ["text","m_0"], + ["string","m_0"], ["rparen","}"], ["lparen","{"], - ["keyword","\\sqrt"], + ["constant.character.escape","\\sqrt"], ["lparen","{"], - ["text","1-"], - ["keyword","\\frac"], + ["string","1-"], + ["constant.character.escape","\\frac"], ["lparen","{"], - ["text","v^2"], + ["string","v^2"], ["rparen","}"], ["lparen","{"], - ["text","c^2"], + ["string","c^2"], ["rparen","}}}"] ],[ "start", ["text"," "], - ["keyword","\\end"], - ["lparen","{"], - ["text","align"], + ["storage.type","\\end"], + ["lparen","{"] +],[ + "block", + ["variable.parameter","align"], ["rparen","}"] ],[ "start", - ["keyword","\\end"], - ["lparen","{"], - ["text","document"], + ["storage.type","\\end"], + ["lparen","{"] +],[ + "block", + ["variable.parameter","document"], ["rparen","}"] ]] \ No newline at end of file From 4115fd24b3887354bea5b3deb537192bcbca4879 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Sun, 10 Aug 2014 01:40:09 +0000 Subject: [PATCH 05/16] adjust tests --- lib/ace/mode/_test/tokens_latex.json | 36 ++++++++++------------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/lib/ace/mode/_test/tokens_latex.json b/lib/ace/mode/_test/tokens_latex.json index 77bd5f1a..0ab5a5ca 100644 --- a/lib/ace/mode/_test/tokens_latex.json +++ b/lib/ace/mode/_test/tokens_latex.json @@ -18,9 +18,7 @@ ],[ "start", ["storage.type","\\begin"], - ["lparen","{"] -],[ - "block", + ["lparen","{"], ["variable.parameter","document"], ["rparen","}"] ],[ @@ -88,48 +86,40 @@ "start", ["text"," "], ["storage.type","\\begin"], - ["lparen","{"] -],[ - "block", + ["lparen","{"], ["variable.parameter","align"], ["rparen","}"] ],[ "start", ["text"," E &= mc^2 "], - ["constant.character.escape","\\\\"] -],[ - "equation", - ["string"," m &= "], - ["constant.character.escape","\\frac"], + ["constant.character.escape","\\\\"], + ["text"," m &= "], + ["storage.type","\\frac"], ["lparen","{"], - ["string","m_0"], + ["text","m_0"], ["rparen","}"], ["lparen","{"], - ["constant.character.escape","\\sqrt"], + ["storage.type","\\sqrt"], ["lparen","{"], - ["string","1-"], - ["constant.character.escape","\\frac"], + ["text","1-"], + ["storage.type","\\frac"], ["lparen","{"], - ["string","v^2"], + ["text","v^2"], ["rparen","}"], ["lparen","{"], - ["string","c^2"], + ["text","c^2"], ["rparen","}}}"] ],[ "start", ["text"," "], ["storage.type","\\end"], - ["lparen","{"] -],[ - "block", + ["lparen","{"], ["variable.parameter","align"], ["rparen","}"] ],[ "start", ["storage.type","\\end"], - ["lparen","{"] -],[ - "block", + ["lparen","{"], ["variable.parameter","document"], ["rparen","}"] ]] \ No newline at end of file From b4dc4b7694e23501c570ea28a7107b34a105146b Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 09:12:46 +0000 Subject: [PATCH 06/16] adjust tests --- lib/ace/mode/_test/tokens_latex.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/_test/tokens_latex.json b/lib/ace/mode/_test/tokens_latex.json index 0ab5a5ca..4ae69afa 100644 --- a/lib/ace/mode/_test/tokens_latex.json +++ b/lib/ace/mode/_test/tokens_latex.json @@ -2,7 +2,7 @@ "start", ["keyword","\\usepackage"], ["lparen","{"], - ["text","amsmath"], + ["storage.type","amsmath"], ["rparen","}"] ],[ "start", From 9fb80fb72cced8cb20ab5c7384c63494bf3a3171 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 09:13:50 +0000 Subject: [PATCH 07/16] simplifications and different highlight for labels etc. --- lib/ace/mode/latex_highlight_rules.js | 41 ++++++++++++--------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 19d7e83a..06db18d8 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -8,21 +8,26 @@ var LatexHighlightRules = function() { this.$rules = { "start" : [{ - token : "keyword", - regex : "\\\\(documentclass|usepackage|label)" + // A comment. Tex comments start with % and go to + // the end of the line + token : "comment", + regex : "%.*$" },{ - // Escaped character (including new line) - token : "constant.character.escape", - regex : "\\\\[^a-zA-Z]" + // Documentclass and usepackage + token : ["keyword","lparen","variable.parameter","rparen", "lparen","storage.type","rparen"], + regex : "(\\\\(?:documentclass|usepackage))(?:(\\[)([^\\]]*)(\\]))?({)(\\w*)(})" + },{ + // A label + token : ["keyword","lparen","variable.parameter","rparen"], + regex : "(\\\\label)(?:({)([^}]*)(}))?" },{ // A block - token : "storage.type", - regex : "\\\\(:?begin|end)", - next : "block" + token : ["storage.type", "lparen","variable.parameter","rparen"], + regex : "(\\\\(?:begin|end))({)(\\w*)(})" },{ // A tex command e.g. \foo token : "storage.type", - regex : "\\\\[a-zA-Z\\d]+" + regex : "\\\\[a-zA-Z]+" }, { // Curly and square braces token : "lparen", @@ -31,26 +36,16 @@ var LatexHighlightRules = function() { // Curly and square braces token : "rparen", regex : "[\\])}]" - }, { - // A comment. Tex comments start with % and go to - // the end of the line - token : "comment", - regex : "%.*$" + },{ + // Escaped character (including new line) + token : "constant.character.escape", + regex : "\\\\[^a-zA-Z]?" },{ // An equation token : "string", regex : "\\${1,2}", next : "equation" }], - "block" : [{ - token : ["lparen","variable.parameter","rparen"], - regex : "({)([^}\\s]*)(}?)", - next : "start" - },{ - token : "", - regex : "", - next : "start" - }], "equation" : [{ token : "string", regex : "\\${1,2}", From 114166a0ceefb5028f5367237091cc0e418473b9 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:02:43 +0000 Subject: [PATCH 08/16] fix code folding --- lib/ace/mode/folding/latex.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ace/mode/folding/latex.js b/lib/ace/mode/folding/latex.js index b80775eb..8695f770 100644 --- a/lib/ace/mode/folding/latex.js +++ b/lib/ace/mode/folding/latex.js @@ -74,7 +74,7 @@ oop.inherits(FoldMode, BaseFoldMode); var stream = new TokenIterator(session, row, column); var token = stream.getCurrentToken(); - if (!token || token.type !== "keyword") + if (!token || token.type !== "storage.type") return; var val = token.value; @@ -96,7 +96,7 @@ oop.inherits(FoldMode, BaseFoldMode); stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; while(token = stream.step()) { - if (token.type !== "keyword") + if (token.type !== "storage.type") continue; var level = keywords[token.value]; if (!level) @@ -123,7 +123,7 @@ oop.inherits(FoldMode, BaseFoldMode); var stream = new TokenIterator(session, row, column); var token = stream.getCurrentToken(); - if (!token || token.type != "keyword") + if (!token || token.type != "storage.type") return; var startLevel = keywords.indexOf(token.value); @@ -131,7 +131,7 @@ oop.inherits(FoldMode, BaseFoldMode); var endRow = row; while(token = stream.stepForward()) { - if (token.type !== "keyword") + if (token.type !== "storage.type") continue; var level = keywords.indexOf(token.value); From 2f56fb208c0465b991a098b069225a682d96acf7 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:03:43 +0000 Subject: [PATCH 09/16] allow comments in equation, default token in equation --- lib/ace/mode/latex_highlight_rules.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 06db18d8..a3345322 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -47,6 +47,9 @@ var LatexHighlightRules = function() { next : "equation" }], "equation" : [{ + token : "comment", + regex : "%.*$" + },{ token : "string", regex : "\\${1,2}", next : "start" @@ -54,8 +57,7 @@ var LatexHighlightRules = function() { token : "constant.character.escape", regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" },{ - token : "string", - regex : "." + defaultToken : "string" }] }; From f79a7a7b0bff09f8a6d5a546fb7535658afdfc2c Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:40:16 +0000 Subject: [PATCH 10/16] exit equation mode on empty lines --- lib/ace/mode/latex_highlight_rules.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index a3345322..05a77c89 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -56,6 +56,10 @@ var LatexHighlightRules = function() { },{ token : "constant.character.escape", regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" + },{ + token : "error", + regex : "^\\s*$", + next : "start" },{ defaultToken : "string" }] From e227811a21d172a74d72719ca63ef415230df401 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:46:27 +0000 Subject: [PATCH 11/16] highlight input command --- lib/ace/mode/latex_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 05a77c89..c1794fab 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -15,7 +15,7 @@ var LatexHighlightRules = function() { },{ // Documentclass and usepackage token : ["keyword","lparen","variable.parameter","rparen", "lparen","storage.type","rparen"], - regex : "(\\\\(?:documentclass|usepackage))(?:(\\[)([^\\]]*)(\\]))?({)(\\w*)(})" + regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)(\\w*)(})" },{ // A label token : ["keyword","lparen","variable.parameter","rparen"], From c3411631a1d0099dce61d9d0b38ddac197fde7aa Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:51:38 +0000 Subject: [PATCH 12/16] highlight input command --- lib/ace/mode/latex_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index c1794fab..56292b7a 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -15,7 +15,7 @@ var LatexHighlightRules = function() { },{ // Documentclass and usepackage token : ["keyword","lparen","variable.parameter","rparen", "lparen","storage.type","rparen"], - regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)(\\w*)(})" + regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})" },{ // A label token : ["keyword","lparen","variable.parameter","rparen"], From b8c111b8322593f426f1b191bcddf217cb93a8bf Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:54:15 +0000 Subject: [PATCH 13/16] add folding for paragraph --- lib/ace/mode/folding/latex.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/folding/latex.js b/lib/ace/mode/folding/latex.js index 8695f770..be950f1d 100644 --- a/lib/ace/mode/folding/latex.js +++ b/lib/ace/mode/folding/latex.js @@ -42,7 +42,7 @@ oop.inherits(FoldMode, BaseFoldMode); (function() { - this.foldingStartMarker = /^\s*\\(begin)|(section|subsection)\b|{\s*$/; + this.foldingStartMarker = /^\s*\\(begin)|(section|subsection|paragraph)\b|{\s*$/; this.foldingStopMarker = /^\s*\\(end)\b|^\s*}/; this.getFoldWidgetRange = function(session, foldStyle, row) { @@ -119,7 +119,7 @@ oop.inherits(FoldMode, BaseFoldMode); }; this.latexSection = function(session, row, column) { - var keywords = ["\\subsection", "\\section", "\\begin", "\\end"]; + var keywords = ["\\subsection", "\\section", "\\begin", "\\end", "\\paragraph"]; var stream = new TokenIterator(session, row, column); var token = stream.getCurrentToken(); From 917c4da39d658e6ea2f5241e8cc80a1a71851cb9 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:57:29 +0000 Subject: [PATCH 14/16] cleanup --- lib/ace/mode/latex_highlight_rules.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 56292b7a..931534ed 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -12,19 +12,19 @@ var LatexHighlightRules = function() { // the end of the line token : "comment", regex : "%.*$" - },{ + }, { // Documentclass and usepackage token : ["keyword","lparen","variable.parameter","rparen", "lparen","storage.type","rparen"], regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})" - },{ + }, { // A label token : ["keyword","lparen","variable.parameter","rparen"], regex : "(\\\\label)(?:({)([^}]*)(}))?" - },{ + }, { // A block token : ["storage.type", "lparen","variable.parameter","rparen"], regex : "(\\\\(?:begin|end))({)(\\w*)(})" - },{ + }, { // A tex command e.g. \foo token : "storage.type", regex : "\\\\[a-zA-Z]+" @@ -36,11 +36,11 @@ var LatexHighlightRules = function() { // Curly and square braces token : "rparen", regex : "[\\])}]" - },{ + }, { // Escaped character (including new line) token : "constant.character.escape", regex : "\\\\[^a-zA-Z]?" - },{ + }, { // An equation token : "string", regex : "\\${1,2}", @@ -49,18 +49,18 @@ var LatexHighlightRules = function() { "equation" : [{ token : "comment", regex : "%.*$" - },{ + }, { token : "string", regex : "\\${1,2}", next : "start" - },{ + }, { token : "constant.character.escape", regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" - },{ + }, { token : "error", regex : "^\\s*$", next : "start" - },{ + }, { defaultToken : "string" }] From b01fe5de13d80825bebb510c9f420acdfa1de42b Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 11:59:42 +0000 Subject: [PATCH 15/16] cleanup --- lib/ace/mode/latex_highlight_rules.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ace/mode/latex_highlight_rules.js b/lib/ace/mode/latex_highlight_rules.js index 931534ed..f3238bfb 100644 --- a/lib/ace/mode/latex_highlight_rules.js +++ b/lib/ace/mode/latex_highlight_rules.js @@ -14,15 +14,15 @@ var LatexHighlightRules = function() { regex : "%.*$" }, { // Documentclass and usepackage - token : ["keyword","lparen","variable.parameter","rparen", "lparen","storage.type","rparen"], + token : ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"], regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})" }, { // A label - token : ["keyword","lparen","variable.parameter","rparen"], + token : ["keyword","lparen", "variable.parameter", "rparen"], regex : "(\\\\label)(?:({)([^}]*)(}))?" }, { // A block - token : ["storage.type", "lparen","variable.parameter","rparen"], + token : ["storage.type", "lparen", "variable.parameter", "rparen"], regex : "(\\\\(?:begin|end))({)(\\w*)(})" }, { // A tex command e.g. \foo From ed320af6f4b0fd9f90ca4506c64fc7e2445a3324 Mon Sep 17 00:00:00 2001 From: Daniel Felder Date: Mon, 11 Aug 2014 12:21:20 +0000 Subject: [PATCH 16/16] fix code folding in equation mode --- lib/ace/mode/folding/latex.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/folding/latex.js b/lib/ace/mode/folding/latex.js index be950f1d..6f20b22e 100644 --- a/lib/ace/mode/folding/latex.js +++ b/lib/ace/mode/folding/latex.js @@ -74,7 +74,7 @@ oop.inherits(FoldMode, BaseFoldMode); var stream = new TokenIterator(session, row, column); var token = stream.getCurrentToken(); - if (!token || token.type !== "storage.type") + if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape")) return; var val = token.value; @@ -96,7 +96,7 @@ oop.inherits(FoldMode, BaseFoldMode); stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; while(token = stream.step()) { - if (token.type !== "storage.type") + if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape")) continue; var level = keywords[token.value]; if (!level)