use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class ComboFlexmarkHtmlAttributesParserTest method assertRendering.
// reverse source and html
@Override
protected void assertRendering(String source, String expectedHtml, String optionsSet) {
DataHolder options = optionsSet == null ? null : getOptions(example(), optionsSet);
String parseSource = expectedHtml;
if (options != null && options.get(NO_FILE_EOL)) {
parseSource = DumpSpecReader.trimTrailingEOL(parseSource);
}
Node node = parser().withOptions(options).parse(parseSource);
String renderedResult = renderer().withOptions(options).render(node);
String expectedResult = source;
actualSource(renderedResult, optionsSet);
boolean useActualHtml = useActualHtml();
// include source for better assertion errors
String expected;
String actual;
if (example() != null && example().getSection() != null) {
StringBuilder outExpected = new StringBuilder();
DumpSpecReader.addSpecExample(outExpected, expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
expected = outExpected.toString();
StringBuilder outActual = new StringBuilder();
DumpSpecReader.addSpecExample(outActual, useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
actual = outActual.toString();
} else {
expected = DumpSpecReader.addSpecExample(expectedResult, expectedHtml, "", optionsSet);
actual = DumpSpecReader.addSpecExample(useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet);
}
specExample(expected, actual, optionsSet);
if (options != null && options.get(FAIL)) {
thrown.expect(ComparisonFailure.class);
}
assertEquals(expected, actual);
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class ComboFlexmarkHtmlParserTest method assertRendering.
// reverse source and html
@Override
protected void assertRendering(String source, String expectedHtml, String optionsSet) {
DataHolder options = optionsSet == null ? null : getOptions(example(), optionsSet);
String parseSource = expectedHtml;
if (options != null && options.get(NO_FILE_EOL)) {
parseSource = DumpSpecReader.trimTrailingEOL(parseSource);
}
Node node = parser().withOptions(options).parse(parseSource);
String renderedResult = renderer().withOptions(options).render(node);
String expectedResult = source;
actualSource(renderedResult, optionsSet);
boolean useActualHtml = useActualHtml();
// include source for better assertion errors
String expected;
String actual;
if (example() != null && example().getSection() != null) {
StringBuilder outExpected = new StringBuilder();
DumpSpecReader.addSpecExample(outExpected, expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
expected = outExpected.toString();
StringBuilder outActual = new StringBuilder();
DumpSpecReader.addSpecExample(outActual, useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
actual = outActual.toString();
} else {
expected = DumpSpecReader.addSpecExample(expectedResult, expectedHtml, "", optionsSet);
actual = DumpSpecReader.addSpecExample(useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet);
}
specExample(expected, actual, optionsSet);
if (options != null && options.get(FAIL)) {
thrown.expect(ComparisonFailure.class);
}
assertEquals(expected, actual);
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class YamlFrontMatterTest method simpleValue.
@Test
public void simpleValue() {
final String input = "---" + "\nhello: world" + "\n..." + "\n" + "\ngreat";
final String rendered = "<p>great</p>\n";
AbstractYamlFrontMatterVisitor visitor = new AbstractYamlFrontMatterVisitor();
Node document = PARSER.parse(input);
visitor.visit(document);
Map<String, List<String>> data = visitor.getData();
assertEquals(1, data.size());
assertEquals("hello", data.keySet().iterator().next());
assertEquals(1, data.get("hello").size());
assertEquals("world", data.get("hello").get(0));
assertRendering(input, rendered);
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class YamlFrontMatterTest method yamlInParagraph.
@Test
public void yamlInParagraph() {
final String input = "# hello\n" + "\nhello markdown world!" + "\n---" + "\nhello: world" + "\n---";
final String rendered = "<h1>hello</h1>\n<h2>hello markdown world!</h2>\n<h2>hello: world</h2>\n";
AbstractYamlFrontMatterVisitor visitor = new AbstractYamlFrontMatterVisitor();
Node document = PARSER.parse(input);
visitor.visit(document);
Map<String, List<String>> data = visitor.getData();
assertTrue(data.isEmpty());
assertRendering(input, rendered);
}
use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.
the class YamlFrontMatterTest method emptyValue.
@Test
public void emptyValue() {
final String input = "---" + "\nkey:" + "\n---" + "\n" + "\ngreat";
final String rendered = "<p>great</p>\n";
AbstractYamlFrontMatterVisitor visitor = new AbstractYamlFrontMatterVisitor();
Node document = PARSER.parse(input);
visitor.visit(document);
Map<String, List<String>> data = visitor.getData();
assertEquals(1, data.size());
assertEquals("key", data.keySet().iterator().next());
assertEquals(0, data.get("key").size());
assertRendering(input, rendered);
}
Aggregations