with(inlines.get(0), new Action<HtmlTag.Inline>() { @Override public void apply(@NonNull HtmlTag.Inline inline) { with(inlines.get(1), new Action<HtmlTag.Inline>() { @Override public void apply(@NonNull HtmlTag.Inline inline) { with(blocks.get(0), new Action<HtmlTag.Block>() { @Override public void apply(@NonNull HtmlTag.Block block) { with(blocks.get(1), new Action<HtmlTag.Block>() { @Override public void apply(@NonNull HtmlTag.Block block) {
@Test public void attributesAreLowerCase() { final MarkwonHtmlParserImpl impl = MarkwonHtmlParserImpl.create(); final StringBuilder output = new StringBuilder(); impl.processFragment(output, "<i CLASS=\"my-class\" dIsAbLeD @HeLLo=\"there\">"); final CaptureInlineTagsAction action = new CaptureInlineTagsAction(); impl.flushInlineTags(output.length(), action); assertTrue(action.called); assertEquals(1, action.tags.size()); with(action.tags.get(0), new Action<HtmlTag.Inline>() { @Override public void apply(@NonNull HtmlTag.Inline inline) { assertEquals("i", inline.name()); with(inline.attributes(), new Action<Map<String, String>>() { @Override public void apply(@NonNull Map<String, String> map) { assertEquals(3, map.size()); assertEquals("my-class", map.get("class")); assertEquals("", map.get("disabled")); assertEquals("there", map.get("@hello")); } }); } }); }
assertEquals(1, action.tags.size()); with(action.tags.get(0), new Action<HtmlTag.Block>() { @Override public void apply(@NonNull HtmlTag.Block block) {
assertEquals(1, action.tags.size()); with(action.tags.get(0), new Action<HtmlTag.Block>() { @Override public void apply(@NonNull HtmlTag.Block block) {
@Test public void flushDoesNotCloseTagsIfNoEndRequested() { final MarkwonHtmlParserImpl impl = MarkwonHtmlParserImpl.create(); final StringBuilder output = new StringBuilder(); impl.processFragment(output, "<div><i><b><em><strong>divibemstrong"); final CaptureInlineTagsAction inlineTagsAction = new CaptureInlineTagsAction(); final CaptureBlockTagsAction blockTagsAction = new CaptureBlockTagsAction(); impl.flushInlineTags(HtmlTag.NO_END, inlineTagsAction); impl.flushBlockTags(HtmlTag.NO_END, blockTagsAction); assertTrue(inlineTagsAction.called); assertTrue(blockTagsAction.called); with(inlineTagsAction.tags, new Action<List<HtmlTag.Inline>>() { @Override public void apply(@NonNull List<HtmlTag.Inline> inlines) { assertEquals(4, inlines.size()); for (HtmlTag.Inline inline : inlines) { assertFalse(inline.isClosed()); assertEquals(HtmlTag.NO_END, inline.end()); } } }); assertEquals(1, blockTagsAction.tags.size()); with(blockTagsAction.tags.get(0), new Action<HtmlTag.Block>() { @Override public void apply(@NonNull HtmlTag.Block block) { assertFalse(block.isClosed()); assertEquals(HtmlTag.NO_END, block.end()); } }); }
assertEquals(1, action.tags.size()); with(action.tags.get(0), new Action<HtmlTag.Block>() { @Override public void apply(@NonNull HtmlTag.Block block) {