diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 24ce99abf..5e4bd91a2 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -11,6 +11,7 @@ This document provides a high-level view of the changes introduced by release. - Fix syntax highlighting in the editor after block-macros with multiple attributes (#1613) - Automatically clear lock for JCEF preview to prevent a blank preview (#1610) +- Improved detection of frontmatter for AsciiDoc files (#1595) === 0.41.13 diff --git a/src/main/java/org/asciidoc/intellij/indexer/AsciiDocIdIndexer.java b/src/main/java/org/asciidoc/intellij/indexer/AsciiDocIdIndexer.java index dec939c3c..de3d9a5b4 100644 --- a/src/main/java/org/asciidoc/intellij/indexer/AsciiDocIdIndexer.java +++ b/src/main/java/org/asciidoc/intellij/indexer/AsciiDocIdIndexer.java @@ -13,7 +13,7 @@ public class AsciiDocIdIndexer extends LexerBasedIdIndexer { @Override public int getVersion() { - return 39; + return 40; } public static Lexer createIndexingLexer(OccurrenceConsumer consumer) { diff --git a/src/main/java/org/asciidoc/intellij/indexer/AsciiDocTodoIndexer.java b/src/main/java/org/asciidoc/intellij/indexer/AsciiDocTodoIndexer.java index 9ff84b935..406fdf75a 100644 --- a/src/main/java/org/asciidoc/intellij/indexer/AsciiDocTodoIndexer.java +++ b/src/main/java/org/asciidoc/intellij/indexer/AsciiDocTodoIndexer.java @@ -12,7 +12,7 @@ public class AsciiDocTodoIndexer extends LexerBasedTodoIndexer { @Override public int getVersion() { - return 28; + return 29; } @NotNull diff --git a/src/main/java/org/asciidoc/intellij/lexer/asciidoc.flex b/src/main/java/org/asciidoc/intellij/lexer/asciidoc.flex index 5456912e7..918d658b8 100644 --- a/src/main/java/org/asciidoc/intellij/lexer/asciidoc.flex +++ b/src/main/java/org/asciidoc/intellij/lexer/asciidoc.flex @@ -571,7 +571,7 @@ ADMONITION = ("NOTE" | "TIP" | "IMPORTANT" | "CAUTION" | "WARNING" ) ":" } { - "---" \n [a-zA-Z0-9_]+ ":" { + "---" \n ([ a-zA-Z0-9_'\"-]+ ":" | [ ]* "#") { if (zzMarkedPos == yylength()) { yybegin(FRONTMATTER); yypushstate(); yypushback(yylength()-3); yybegin(EOL_POP); return AsciiDocTokenTypes.FRONTMATTER_DELIMITER; diff --git a/src/main/java/org/asciidoc/intellij/parser/AsciiDocFileElementType.java b/src/main/java/org/asciidoc/intellij/parser/AsciiDocFileElementType.java index 527c62aa1..822652b00 100644 --- a/src/main/java/org/asciidoc/intellij/parser/AsciiDocFileElementType.java +++ b/src/main/java/org/asciidoc/intellij/parser/AsciiDocFileElementType.java @@ -13,6 +13,6 @@ public AsciiDocFileElementType() { @Override public int getStubVersion() { - return super.getStubVersion() + 56; + return super.getStubVersion() + 57; } } diff --git a/src/main/java/org/asciidoc/intellij/parser/AsciiDocWordsScanner.java b/src/main/java/org/asciidoc/intellij/parser/AsciiDocWordsScanner.java index d7f1fa19b..59437ce0a 100644 --- a/src/main/java/org/asciidoc/intellij/parser/AsciiDocWordsScanner.java +++ b/src/main/java/org/asciidoc/intellij/parser/AsciiDocWordsScanner.java @@ -10,7 +10,7 @@ public class AsciiDocWordsScanner extends DefaultWordsScanner { @Override public int getVersion() { - return 31; + return 32; } public AsciiDocWordsScanner() { diff --git a/src/test/java/org/asciidoc/intellij/lexer/AsciiDocLexerTest.java b/src/test/java/org/asciidoc/intellij/lexer/AsciiDocLexerTest.java index 4203a0a56..89bf55dcd 100644 --- a/src/test/java/org/asciidoc/intellij/lexer/AsciiDocLexerTest.java +++ b/src/test/java/org/asciidoc/intellij/lexer/AsciiDocLexerTest.java @@ -3334,10 +3334,19 @@ public void testEmailWithPrefixButNoSquareBrackets() { } public void testFrontmatter() { - doTest("---\nhi: ho\n---", + doTest("---\nhi-hi: ho\n---", "AsciiDoc:FRONTMATTER_DELIMITER ('---')\n" + "AsciiDoc:LINE_BREAK ('\\n')\n" + - "AsciiDoc:FRONTMATTER ('hi: ho')\n" + + "AsciiDoc:FRONTMATTER ('hi-hi: ho')\n" + + "AsciiDoc:LINE_BREAK ('\\n')\n" + + "AsciiDoc:FRONTMATTER_DELIMITER ('---')"); + } + + public void testFrontmatterWithComment() { + doTest("---\n# comment\n---", + "AsciiDoc:FRONTMATTER_DELIMITER ('---')\n" + + "AsciiDoc:LINE_BREAK ('\\n')\n" + + "AsciiDoc:FRONTMATTER ('# comment')\n" + "AsciiDoc:LINE_BREAK ('\\n')\n" + "AsciiDoc:FRONTMATTER_DELIMITER ('---')"); }