Skip to content

Commit

Permalink
Add support for GitLab Flavored Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
valentjn committed Jan 13, 2021
1 parent 4c04d39 commit 241b0db
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

## 9.1.0 (upcoming)

- Add support for [GitLab Flavored Markdown](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md), especially inline math (e.g., ``$`E = mc^2`$``)
- Use Flexmark's YAML Front Matter extension to ignore YAML front matter in Markdown instead of own handling
- Print Flexmark AST of Markdown documents to log when [`ltex.ltex-ls.logLevel`](https://valentjn.github.io/vscode-ltex/docs/settings.html#ltexltex-lsloglevel) is `"finest"`

Expand Down
5 changes: 5 additions & 0 deletions ltexls-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<artifactId>flexmark-ext-yaml-front-matter</artifactId>
<version>0.62.2</version>
</dependency>
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-ext-gitlab</artifactId>
<version>0.62.2</version>
</dependency>
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-test-util</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.bsplines.ltexls.parsing.markdown;

import com.vladsch.flexmark.ext.gitlab.GitLabExtension;
import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterExtension;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.test.util.AstCollectingVisitor;
Expand All @@ -29,7 +30,10 @@

public class MarkdownAnnotatedTextBuilder extends CodeAnnotatedTextBuilder {
private static final DataHolder parserOptions = new MutableDataSet().set(Parser.EXTENSIONS,
Arrays.asList(YamlFrontMatterExtension.create()));
Arrays.asList(
GitLabExtension.create(),
YamlFrontMatterExtension.create()
));

private Parser parser = Parser.builder(parserOptions).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private static List<MarkdownNodeSignature> createDefaultMarkdownNodeSignatures()
list.add(new MarkdownNodeSignature("Code", MarkdownNodeSignature.Action.DUMMY));
list.add(new MarkdownNodeSignature("CodeBlock"));
list.add(new MarkdownNodeSignature("FencedCodeBlock"));
list.add(new MarkdownNodeSignature("GitLabInlineMath", MarkdownNodeSignature.Action.DUMMY));
list.add(new MarkdownNodeSignature("IndentedCodeBlock"));

return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public void test() throws IOException {
assertPlainText(
"This is a test: `inline code`.\n\n```\ncode block\n```\n\nThis is another sentence.\n",
"This is a test: Dummy0.\n\n\n\n\n\nThis is another sentence.\n");
assertPlainText(
"This is a test: $`E = mc^2`$.\n\n```math\na^2 + b^2 = c^2\n```\n\nThis is another test.\n",
"This is a test: Dummy0.\n\n\n\n\n\nThis is another test.\n");

Map<String, String> markdownNodes = new HashMap<>();
markdownNodes.put("Code", "default");
Expand Down

0 comments on commit 241b0db

Please sign in to comment.