Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import static org.openhab.tools.analysis.checkstyle.api.CheckConstants.*;

import java.io.File;
import java.util.List;

import org.openhab.tools.analysis.checkstyle.api.AbstractStaticCheck;

import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
import com.puppycrawl.tools.checkstyle.api.FileText;
import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterExtension;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.data.MutableDataSet;
Expand Down Expand Up @@ -54,6 +56,7 @@ private void checkReadMe(FileText fileText) {
MutableDataSet options = new MutableDataSet();
// By setting this option to true, the parser provides line numbers in the original markdown text for each node
options.set(Parser.TRACK_DOCUMENT_LINES, true);
options.set(Parser.EXTENSIONS, List.of(YamlFrontMatterExtension.create()));

Node readmeMarkdownNode = parseMarkdown(fileText, options);
// CallBack is used in order to use the protected log method of the AbstractStaticCheck in the Visitor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ public void testDocFolderWrong() throws Exception {
verifyMarkDownFile("testDocFolderWrong", expectedMessages);
}

@Test
public void testFrontMatterIgnored() throws Exception {
verifyMarkDownFile("testFrontMatterIgnored", noMessagesExpected());
}

private void createValidConfig() {
config = createModuleConfig(MarkdownCheck.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Sample document
description: |
# not a header
* not a list
```
not code formatting
```
children:
- ["doc/test1", "Test1"]
- ["doc/test2", "Test2"]
---

# Actual Header

Body text.