Permalink
Browse files

Merge pull request #1058 from amolenaar/frontmatter-crlf

Allow Front matters to work with windows line endings
  • Loading branch information...
2 parents 95babff + 22e274b commit d3c6870576fcc7084e9a2601ef4c3ac6f6c661de @amolenaar amolenaar committed on GitHub Jun 21, 2017
@@ -8,15 +8,17 @@
public static final FrontMatter symbolType = new FrontMatter();
public static final SymbolType keyValueSymbolType = new SymbolType("KeyValue");
- private static final String FRONT_MATTER_DELIMITER = "---\n";
+ private static final String FRONT_MATTER_DELIMITER_LF = "---\n";
+ private static final String FRONT_MATTER_DELIMITER_CRLF = "---\r\n";
private static SymbolProvider SYMBOL_PROVIDER = new SymbolProvider(new SymbolType[] {
CloseFrontMatter.symbolType, SymbolType.Colon, SymbolType.Whitespace, SymbolType.Newline, SymbolType.Text
});
FrontMatter() {
super("FrontMatter");
- wikiMatcher(new Matcher().startLine().string(FRONT_MATTER_DELIMITER));
+ wikiMatcher(new Matcher().startLine().string(FRONT_MATTER_DELIMITER_LF));
+ wikiMatcher(new Matcher().startLine().string(FRONT_MATTER_DELIMITER_CRLF));
wikiRule(this);
htmlTranslation(this);
}
@@ -81,7 +83,8 @@ public String toTarget(Translator translator, Symbol symbol) {
private CloseFrontMatter() {
super("EndOfFrontMatter");
- wikiMatcher(new Matcher().startLine().string(FRONT_MATTER_DELIMITER));
+ wikiMatcher(new Matcher().startLine().string(FRONT_MATTER_DELIMITER_LF));
+ wikiMatcher(new Matcher().startLine().string(FRONT_MATTER_DELIMITER_CRLF));
}
}
@@ -46,6 +46,16 @@ public void parseFrontMatterWithText() {
}
@Test
+ public void parseFrontMatterWithTextAndWindowsLineEndings() {
+ assertParses(
+ "---\r\n" +
+ "test\r\n" +
+ "---\r\n" +
+ "WikiText",
+ "SymbolList[FrontMatter[KeyValue[Text, Text]], Text]");
+ }
+
+ @Test
public void parseFrontMatterWithKeyValueText() {
assertParses(
"---\n" +

0 comments on commit d3c6870

Please sign in to comment.