Skip to content
Snippets Groups Projects
Commit 4449d55f authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[textile mode] Require non-space characters directly inside phrase modifiers

Issue #2967
parent b5e401f5
No related branches found
No related tags found
No related merge requests found
......@@ -411,4 +411,7 @@
MT('phrase-non-word',
'[negative -x-] aaa-bbb ccc-ddd [negative -eee-] fff [negative -ggg-]');
MT('phrase-lone-dash',
'foo - bar - baz');
})();
......@@ -117,14 +117,16 @@
}
function togglePhraseModifier(stream, state, phraseModifier, closeRE, openSize) {
var charBefore = stream.pos > openSize ? stream.string.charAt(stream.pos - openSize - 1) : null;
var charAfter = stream.peek();
if (state[phraseModifier]) {
if (stream.match(/^($|\W)/, false)) {
if ((!charAfter || /\W/.test(charAfter)) && charBefore && /\S/.test(charBefore)) {
var type = tokenStyles(state);
state[phraseModifier] = false;
return type;
}
} else if ((stream.pos == openSize || /\W/.test(stream.string.charAt(stream.pos - 1 - openSize))) &&
stream.match(new RegExp("^.*" + closeRE.source + "(?=\\W|$)"), false)) {
} else if ((!charBefore || /\W/.test(charBefore)) && charAfter && /\S/.test(charAfter) &&
stream.match(new RegExp("^.*\\S" + closeRE.source + "(?:\\W|$)"), false)) {
state[phraseModifier] = true;
state.mode = Modes.attributes;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment