From 429749c8b4ff84812e621d101bb7061d3d895a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Tue, 2 Apr 2019 22:28:35 +0200 Subject: [PATCH 1/3] Avoid endless loop scanning for ')' --- src/bibtex_js.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bibtex_js.js b/src/bibtex_js.js index f5c6ba4..b845ef5 100644 --- a/src/bibtex_js.js +++ b/src/bibtex_js.js @@ -277,7 +277,7 @@ function BibtexParser() { end = this.pos + 1; if (this.tryMatch("}")) { this.match("}"); - } else { + } else if (this.tryMatch(")")) { this.match(")"); } if (this.tryMatch(",")) { @@ -3568,4 +3568,4 @@ var latex_to_unicode = { "{\\o}": "\u00D8", "{\AA}": "\u212B", "\\relax ": "" -}; \ No newline at end of file +}; From 5283012776de955e99a4fc8a0fea2611095437b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Thu, 4 Apr 2019 19:36:22 +0200 Subject: [PATCH 2/3] Added regex for e.g. \v{r} to LaTeX -> Unicode --- src/bibtex_js.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bibtex_js.js b/src/bibtex_js.js index b845ef5..d176c73 100644 --- a/src/bibtex_js.js +++ b/src/bibtex_js.js @@ -312,7 +312,8 @@ function BibtexDisplay() { this.regExps.push(new RegExp("\\\\\\W*\{\\w+\}")); // 2 \[]{\[]} this.regExps.push(new RegExp("\\\\\\W*\\w+\\s")); // 3 \[] this.regExps.push(new RegExp("\\\\\\W*\\w+")); // 4 \[] - this.regExps.push(new RegExp("\\\\(?![:\\\\\])\\W{1}")); // 5 + this.regExps.push(new RegExp("\\\\\\w\{\\w\}")); // 5 \\\w{\w} to match e.g. \v{r} + this.regExps.push(new RegExp("\\\\(?![:\\\\\])\\W{1}")); // 6 this.fixValue = function(value) { do { From 92fc824c5f9dcd8a499c79debb9c5bba05180988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Thu, 4 Apr 2019 19:37:35 +0200 Subject: [PATCH 3/3] Added code to remove $ .. $ around math --- src/bibtex_js.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bibtex_js.js b/src/bibtex_js.js index d176c73..52a6a2f 100644 --- a/src/bibtex_js.js +++ b/src/bibtex_js.js @@ -348,6 +348,7 @@ function BibtexDisplay() { } } value = value.replace(/[\{|\}]/g, ''); + value = value.replace(/\$(.*?)\$/, '$1'); // remove $..$ used for math env. return value; }