use of org.intellij.markdown.IElementType in project intellij-plugins by JetBrains.
the class MarkdownPreviewFileEditor method generateMarkdownHtml.
@NotNull
private static String generateMarkdownHtml(@NotNull VirtualFile file, @NotNull String text) {
final VirtualFile parent = file.getParent();
final URI baseUri = parent != null ? new File(parent.getPath()).toURI() : null;
final ASTNode parsedTree = new MarkdownParser(MarkdownParserManager.FLAVOUR).buildMarkdownTreeFromString(text);
final Map<IElementType, GeneratingProvider> htmlGeneratingProviders = MarkdownParserManager.FLAVOUR.createHtmlGeneratingProviders(LinkMap.Builder.buildLinkMap(parsedTree, text), baseUri);
return new HtmlGenerator(text, parsedTree, htmlGeneratingProviders, true).generateHtml();
}
use of org.intellij.markdown.IElementType in project intellij-plugins by JetBrains.
the class PsiBuilderFillingVisitor method visitNode.
@Override
public void visitNode(@NotNull ASTNode node) {
if (node instanceof LeafASTNode) {
/* a hack for the link reference definitions:
* they are being parsed independent from link references and
* the link titles and urls are tokens instead of composite elements
*/
final IElementType type = node.getType();
if (type != MarkdownElementTypes.LINK_LABEL && type != MarkdownElementTypes.LINK_DESTINATION) {
return;
}
}
ensureBuilderInPosition(node.getStartOffset());
final PsiBuilder.Marker marker = builder.mark();
super.visitNode(node);
ensureBuilderInPosition(node.getEndOffset());
marker.done(MarkdownElementType.platformType(node.getType()));
}
Aggregations