Skip to content

Commit

Permalink
Fix Sinker, add IT
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsromero committed Jan 27, 2024
1 parent 43d5517 commit ef8c6ae
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public class HelloWorld {
* Walnuts
* Almonds

==== Unordered list with formatting

* *Apples*
* _Oranges_
* ~Walnuts~
* `Almonds`
* https://some-link.here[link]

==== Ordered list

. Protons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,41 @@ new HtmlAsserter(htmlContent).with { asserter ->
asserter.containsSectionTitle("Code blocks", 3)

asserter.containsSectionTitle("Lists", 3)

asserter.containsSectionTitle("Unordered list", 4)
asserter.containsUnorderedList("Apples", "Oranges", "Walnuts", "Almonds")

asserter.containsSectionTitle("Unordered list with formatting", 4)
asserter.containsUnorderedList(strong("Apples"), italics("Oranges"), subscript("Walnuts"), monospace("Almonds"), htmlLink('https://some-link.here', 'link'))

asserter.containsSectionTitle("Ordered list", 4)
asserter.containsOrderedList("Protons", "Electrons", "Neutrons")

}

String strong(String text) {
return htmlElement('strong', text)
}

String italics(String text) {
return htmlElement('em', text)
}

String subscript(String text) {
return htmlElement('sub', text)
}

String monospace(String text) {
return htmlElement('code', text)
}

String htmlLink(String url, String label) {
return "<a href=\"${url}\">${label}</a>"
}

String htmlElement(String element, String text) {
return "<${element}>${text}</${element}>"
}

for (String unexpectedFile : unexpectedFiles) {
File candidate = new File(outputDir, unexpectedFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.asciidoctor.maven.site.ast.processors.ListingNodeProcessor;
import org.asciidoctor.maven.site.ast.processors.LiteralNodeProcessor;
import org.asciidoctor.maven.site.ast.processors.OrderedListNodeProcessor;
import org.asciidoctor.maven.site.ast.processors.ParagraphNodeProcessor;
import org.asciidoctor.maven.site.ast.processors.PreambleNodeProcessor;
import org.asciidoctor.maven.site.ast.processors.SectionNodeProcessor;
import org.asciidoctor.maven.site.ast.processors.TableNodeProcessor;
Expand Down Expand Up @@ -49,6 +50,7 @@ public NodesSinker(Sink sink) {
new ImageNodeProcessor(sink),
new ListingNodeProcessor(sink),
new LiteralNodeProcessor(sink),
new ParagraphNodeProcessor(sink),
new PreambleNodeProcessor(sink),
new SectionNodeProcessor(sink),
new TableNodeProcessor(sink),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void process(StructuralNode node) {
else
sink.numberedListItem();

sink.rawText(item.getText());
String text = item.getText();
sink.rawText(text == null ? "" : text);

for (StructuralNode subNode : node.getBlocks()) {
for (NodeProcessor np : nodeProcessors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ void should_convert_html_without_any_configuration() throws FileNotFoundExceptio
String result = parse(parser, srcAsciidoc);

assertThat(result)
.isEqualTo("<h1>Document Title</h1><p>Preamble paragraph.</p>" +
.isEqualTo("<h1>Document Title</h1>" +
"<p>Preamble paragraph.</p>" +
"<h2><a name=\"Section_A\"></a>Section A</h2>" +
"<p><strong>Section A</strong> paragraph.</p>" +
"<h3><a name=\"Section_A_Subsection\"></a>Section A Subsection</h3>" +
"<p><strong>Section A</strong> <em>subsection</em> paragraph.</p>" +
"<p><strong>Section A</strong> 'subsection' paragraph.</p>" +
"<h2><a name=\"Section_B\"></a>Section B</h2>" +
"<p><strong>Section B</strong> paragraph.</p>" +
"<ul>" +
Expand Down

0 comments on commit ef8c6ae

Please sign in to comment.