When processing markdown, GitHub supports the @
-syntax to mention a username or team. How can such mentions be processed with Flexmark-Java? With following code snippet, Hello, @world !
is reported as a single Text
node where I would expect to get world
reported separately as some kind of MentionsNode:
final Parser parser = Parser.builder(new Parser.Builder()).build();
final Document document = parser.parse("Hello, @world !");
new NodeVisitor(Collections.emptyList()) {
public void visit(Node node) {
System.out.println("Node: " + node);
super.visit(node);
}
}.visit(document);
Output:
Node: Document{}
Node: Paragraph{}
Node: Text{text=Hello, @world !}
There is a corresponding extension for this:
final MutableDataHolder options = new MutableDataSet()
.set(Parser.EXTENSIONS, Collections.singletonList(GfmUsersExtension.create()));
final Parser parser = Parser.builder(options).build();
final Document document = parser.parse("Hello, @world, and #1!");
...