Skip to content

Commit

Permalink
Improved detection of frontmatter for AsciiDoc files (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed May 2, 2024
1 parent 3d6a16f commit 68ead9f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AsciiDocIdIndexer extends LexerBasedIdIndexer {

@Override
public int getVersion() {
return 39;
return 40;
}

public static Lexer createIndexingLexer(OccurrenceConsumer consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AsciiDocTodoIndexer extends LexerBasedTodoIndexer {

@Override
public int getVersion() {
return 28;
return 29;
}

@NotNull
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/asciidoc/intellij/lexer/asciidoc.flex
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ ADMONITION = ("NOTE" | "TIP" | "IMPORTANT" | "CAUTION" | "WARNING" ) ":"
}

<MULTILINE> {
"---" \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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public AsciiDocFileElementType() {

@Override
public int getStubVersion() {
return super.getStubVersion() + 56;
return super.getStubVersion() + 57;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AsciiDocWordsScanner extends DefaultWordsScanner {

@Override
public int getVersion() {
return 31;
return 32;
}

public AsciiDocWordsScanner() {
Expand Down
13 changes: 11 additions & 2 deletions src/test/java/org/asciidoc/intellij/lexer/AsciiDocLexerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ('---')");
}
Expand Down

0 comments on commit 68ead9f

Please sign in to comment.