- update to r279 of google-code-prettify (fix issue 217: regex matching after runs of punctuation) (note some tests failed in this revision)
diff --git a/src/prettify/parser/Prettify.java b/src/prettify/parser/Prettify.java index 3080e04..df70e79 100644 --- a/src/prettify/parser/Prettify.java +++ b/src/prettify/parser/Prettify.java
@@ -733,7 +733,8 @@ + "[a-z]*", Pattern.CASE_INSENSITIVE), null, "0123456789"})); - // Don't treat escaped quotes in bash as starting strings. See issue 144. + // Don't treat escaped quotes in bash as starting strings. + // See issue 144. fallthroughStylePatterns.add(Arrays.asList(new Object[]{PR_PLAIN, Pattern.compile("^\\\\[\\s\\S]?"), null})); @@ -773,9 +774,12 @@ // If that does turn out to be a problem, we should change the below // when hc is truthy to include # in the run of punctuation characters // only when not followint [|&;<>]. - final String punctation = "^.[^\\s\\w\\.$@\\'\\\"\\`\\/\\\\]*"; + String punctuation = "^.[^\\s\\w.$@'\"`/\\\\]*"; + if (options.get("regexLiterals") != null) { + punctuation += "(?!\\s*/)"; + } fallthroughStylePatterns.add(Arrays.asList(new Object[]{PR_PUNCTUATION, - Pattern.compile(punctation), + Pattern.compile(punctuation), null})); return new CreateSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
diff --git a/test/prettify/PrettifyTest.java b/test/prettify/PrettifyTest.java index d00d873..907de3b 100644 --- a/test/prettify/PrettifyTest.java +++ b/test/prettify/PrettifyTest.java
@@ -173,6 +173,7 @@ test("llvm", "llvm", false); test("pascal", "pascal_lang", false); test("basic", "basic_lang", false); + test("js", "issue217", false); } /**
diff --git a/test/prettify/PrettifyTest/result/issue217.txt b/test/prettify/PrettifyTest/result/issue217.txt new file mode 100644 index 0000000..2891a20 --- /dev/null +++ b/test/prettify/PrettifyTest/result/issue217.txt
@@ -0,0 +1,3 @@ +`KWDif`END`PUN(!`END`STR/^https?:\/\//`END`PLNi`END`PUN.`END`PLNtest`END`PUN(`END`PLNval`END`PUN)`END`PLN `END`PUN&&`END`PLN foo `END`PUN==`END`PLN `END`STR'bar'`END`PUN)`END`PLN `END`PUN{`END`PLN + val `END`PUN=`END`PLN `END`STR'http://'`END`PLN `END`PUN+`END`PLN val`END`PUN;`END`PLN +`END`PUN}`END \ No newline at end of file
diff --git a/test/prettify/PrettifyTest/source/issue217.txt b/test/prettify/PrettifyTest/source/issue217.txt new file mode 100644 index 0000000..821a973 --- /dev/null +++ b/test/prettify/PrettifyTest/source/issue217.txt
@@ -0,0 +1,4 @@ +<pre id="issue217" class="prettyprint lang-js"> +if(!/^https?:\/\//i.test(val) && foo == 'bar') { + val = 'http://' + val; +} \ No newline at end of file