Skip to content

Commit b4b6df6

Browse files
committed
Fix highlighting of **foo***bar** sequences
Closes: #15
1 parent d9032e4 commit b4b6df6

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

grammars/muse.cson

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,23 @@ repository:
141141
# ***Bold italic***
142142
name: "markup.bold.italic.strong.emphasis.muse"
143143
begin: "(?<=\\W|^)(\\*{3})(?=\\S)"
144-
end: "(?<=\\S)\\1(?=\\W|$)|(?=^[ \\t]*$)"
144+
end: "(?<=\\S)\\1(?!\\*+\\w)(?=\\W|$)|(?=^[ \\t]*$)"
145145
beginCaptures: 1: name: "punctuation.definition.emphasis.begin.muse"
146146
endCaptures: 0: name: "punctuation.definition.emphasis.end.muse"
147147
patterns: [include: "#inlineInnards"]
148148
},{
149149
# **Bold**
150150
name: "markup.bold.strong.emphasis.muse"
151151
begin: "(?<=\\W|^)(\\*{2})(?=\\S)"
152-
end: "(?<=\\S)\\1(?=\\W|$)|(?=^[ \\t]*$)"
152+
end: "(?<=\\S)\\1(?!\\*+\\w)(?=\\W|$)|(?=^[ \\t]*$)"
153153
beginCaptures: 1: name: "punctuation.definition.emphasis.begin.muse"
154154
endCaptures: 0: name: "punctuation.definition.emphasis.end.muse"
155155
patterns: [include: "#inlineInnards"]
156156
},{
157157
# *Italic*
158158
name: "markup.italic.emphasis.muse"
159159
begin: "(?<=\\W|^)\\*(?=\\S)"
160-
end: "(?<=\\S)\\*(?=\\W|$)|(?=^[ \\t]*$)"
160+
end: "(?<=\\S)\\*(?!\\*+\\w)(?=\\W|$)|(?=^[ \\t]*$)"
161161
beginCaptures: 0: name: "punctuation.definition.emphasis.begin.muse"
162162
endCaptures: 0: name: "punctuation.definition.emphasis.end.muse"
163163
patterns: [include: "#inlineInnards"]
@@ -262,7 +262,7 @@ repository:
262262
patterns: [{
263263
# Swallow asterisks embedded between word characters.
264264
# See: Alhadis/language-emacs-lisp#5, jgm/pandoc#5821
265-
match: "(?<=\\w)\\*+(?=\\w)"
265+
match: "(?:(?=\\G|^)|(?<=[\\w*]))\\*+(?=\\w)"
266266

267267
}, include: "#inline"]
268268

spec/muse-spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ describe("Muse grammar", () => {
8787
expect(lines[1][4]).to.eql({value: "", scopes: [...baseScopes]});
8888
expect(lines[2][0]).to.eql({value: "", scopes: [...baseScopes]});
8989
});
90+
91+
it("tokenises `**foo***bar**` correctly", () => {
92+
const {tokens} = muse.tokenizeLine("**foo***bar**");
93+
const baseScopes = ["text.muse", "meta.document.muse", "markup.bold.strong.emphasis.muse"];
94+
expect(tokens[0]).to.eql({value: "**", scopes: [...baseScopes, "punctuation.definition.emphasis.begin.muse"]});
95+
expect(tokens[1]).to.eql({value: "foo", scopes: [...baseScopes]});
96+
expect(tokens[2]).to.eql({value: "***", scopes: [...baseScopes]});
97+
expect(tokens[3]).to.eql({value: "bar", scopes: [...baseScopes]});
98+
expect(tokens[4]).to.eql({value: "**", scopes: [...baseScopes, "punctuation.definition.emphasis.end.muse"]});
99+
});
90100
});
91101

92102
describe("Fixture highlighting", function(){

0 commit comments

Comments
 (0)