use of org.commonmark.node.Node in project toolkit by googleapis.
the class GoCommentReformatter method reformat.
@Override
public String reformat(String comment) {
Node root = PARSER.parse(comment);
GoVisitor visitor = new GoVisitor();
try {
root.accept(visitor);
return visitor.toString();
} catch (ErrorMarkdownVisitor.UnimplementedRenderException e) {
LOGGER.log(Level.WARNING, "markdown contains elements we don't handle; copying doc verbatim", e);
return comment;
}
}
use of org.commonmark.node.Node in project hippo by NHS-digital-website.
the class CommonmarkMarkdownConverter method renderMarkdownText.
private String renderMarkdownText(final String markdown, final String headingIdPrefix, int topHeadingLevel) {
final List<Extension> extensions = singletonList(TablesExtension.create());
final Node document = parse(markdown, extensions);
normalizeHeadingsLevels(document, topHeadingLevel);
addBreaksBeforeH2Headings(document);
return renderMarkdownModel(document, extensions, headingIdPrefix);
}
use of org.commonmark.node.Node in project hippo by NHS-digital-website.
the class ThematicBreakAttributeProviderTest method ignoresElementOtherThanThematicBreak.
@Test
public void ignoresElementOtherThanThematicBreak() {
// given
final Node nodeOtherThanThematicBreak = new TableBlock();
// when
thematicBreakAttributeProvider.setAttributes(nodeOtherThanThematicBreak, "tagName is ignored", attributes);
// then
then(attributes).shouldHaveZeroInteractions();
}
use of org.commonmark.node.Node in project hippo by NHS-digital-website.
the class CodeAttributeProviderTest method setsCodeInlineCssClassOnCodeElement.
@Test
public void setsCodeInlineCssClassOnCodeElement() {
// given
final Node nodeCode = new Code();
// when
codeAttributeProvider.setAttributes(nodeCode, "tagName is ignored", attributes);
// then
then(attributes).should().put("class", "nhsd-a-text-highlight nhsd-a-text-highlight--code");
then(attributes).shouldHaveNoMoreInteractions();
}
use of org.commonmark.node.Node in project hippo by NHS-digital-website.
the class ListAttributeProviderTest method setsCssClassOnOrderedListElement.
@Test
public void setsCssClassOnOrderedListElement() {
// given
final Node nodeOrderedList = new OrderedList();
// when
listAttributeProvider.setAttributes(nodeOrderedList, "tagName is ignored", attributes);
// then
then(attributes).should().put("class", "nhsd-t-list nhsd-t-list--number");
then(attributes).shouldHaveNoMoreInteractions();
}
Aggregations