Skip to content

Commit 10067fb

Browse files
committed
Add pattern-matching for Emacs Muse underlines
References: #7
1 parent f0b35d4 commit 10067fb

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

grammars/muse.cson

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ repository:
254254
{include: "#link"}
255255
{include: "#footnoteReference"}
256256
{include: "#nbsp"}
257+
{include: "#underline"}
257258
]
258259

259260

@@ -794,6 +795,16 @@ repository:
794795
2: name: "keyword.operator.key-value.separator.muse"
795796

796797

798+
# Underlined text (not supported in AmuseWiki)
799+
underline:
800+
name: "constant.other.reference.link.muse"
801+
begin: "(?<=\\W|^)_(?=[^\\s_])"
802+
end: "(?<=[^\\s_])_(?=\\W|$)|(?=^[ \\t]*$)"
803+
beginCaptures: 0: name: "punctuation.definition.emphasis.begin.muse"
804+
endCaptures: 0: name: "punctuation.definition.emphasis.end.muse"
805+
patterns: [include: "#inline"]
806+
807+
797808
# Poetic stanza
798809
verse:
799810
name: "markup.quote.verse.muse"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Foo _underline_ baz
2+
3+
Foo _under line_ baz
4+
5+
Foo _underline _ baz
6+
7+
Foo _ underline_ baz
8+
9+
Foo _ under line _ baz
10+
11+
Foo _ under _ line _ baz
12+
13+
Foo _under_line_ baz
14+
15+
Foo __underline__ baz
16+
17+
Foo __under line__ baz
18+
19+
Foo __under__line__ baz
20+
21+
Foo _under_line under_line_ baz
22+
23+
Foo _underline *italic* underline_ baz
24+
25+
Foo _underline **bold** underline_ baz
26+
27+
Foo _underline ***bold italic*** underline_ baz
28+
29+
Foo _underline
30+
underline_ bar
31+
32+
_underline
33+
underline_ bar
34+
35+
Foo _under line
36+
under line_ bar
37+
38+
_underline
39+
underline_ bar
40+
41+
Foo_ underline_ baz
42+
43+
Foo _underline_unclosed italic
44+
45+
Foo _underline_underline_ baz
46+
47+
_underline

spec/muse-spec.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,17 @@ describe("Muse grammar", () => {
8181
});
8282

8383
for(const filename of files){
84-
const inputFile = fs.readFileSync(join(inputDir, filename), "utf8");
85-
const outputFile = fs.readFileSync(join(outputDir, filename + ".json"), "utf8");
84+
const inputPath = join(inputDir, filename);
85+
const outputPath = join(outputDir, filename + ".json");
86+
87+
// Ignore pending fixtures
88+
if(!fs.existsSync(outputPath)){
89+
it.skip(`tokenises ${filename}`);
90+
continue;
91+
}
92+
93+
const inputFile = fs.readFileSync(inputPath, "utf8");
94+
const outputFile = fs.readFileSync(outputPath, "utf8");
8695

8796
it(`tokenises ${filename}`, () => {
8897
const input = muse.tokenizeLines(inputFile);

0 commit comments

Comments
 (0)