Merge f442121826160cdad311b576ba2db261b05ba8fb into 2ea148c30a07f91ffa37c0aa36af1cf2670441af
This commit is contained in:
commit
f672a4750b
@ -39,6 +39,19 @@
|
|||||||
"image"
|
"image"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"javaClassName": "io.noties.markwon.app.samples.html.HtmlOrderedListNumbersSample",
|
||||||
|
"id": "20210201140502",
|
||||||
|
"title": "HTML Ordered list numbers",
|
||||||
|
"description": "",
|
||||||
|
"artifacts": [
|
||||||
|
"HTML"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"rendering",
|
||||||
|
"html"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"javaClassName": "io.noties.markwon.app.samples.html.InspectHtmlTextSample",
|
"javaClassName": "io.noties.markwon.app.samples.html.InspectHtmlTextSample",
|
||||||
"id": "20210201140501",
|
"id": "20210201140501",
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package io.noties.markwon.app.samples.html;
|
||||||
|
|
||||||
|
import io.noties.markwon.Markwon;
|
||||||
|
import io.noties.markwon.app.sample.ui.MarkwonTextViewSample;
|
||||||
|
import io.noties.markwon.html.HtmlPlugin;
|
||||||
|
import io.noties.markwon.sample.annotations.MarkwonArtifact;
|
||||||
|
import io.noties.markwon.sample.annotations.MarkwonSampleInfo;
|
||||||
|
import io.noties.markwon.sample.annotations.Tag;
|
||||||
|
|
||||||
|
@MarkwonSampleInfo(
|
||||||
|
id = "20210201140502",
|
||||||
|
title = "HTML Ordered list numbers",
|
||||||
|
artifacts = MarkwonArtifact.HTML,
|
||||||
|
tags = {Tag.rendering, Tag.html}
|
||||||
|
)
|
||||||
|
public class HtmlOrderedListNumbersSample extends MarkwonTextViewSample {
|
||||||
|
@Override
|
||||||
|
public void render() {
|
||||||
|
final String md = "# HTML Ordered lists\n\n" +
|
||||||
|
"<ol start=\"7\">" +
|
||||||
|
" <li>July</li>\n" +
|
||||||
|
" <li>August</li>\n" +
|
||||||
|
" <li>September</li>\n" +
|
||||||
|
" <li>October</li>\n" +
|
||||||
|
" <li>November</li>\n" +
|
||||||
|
" <li>December</li>\n" +
|
||||||
|
"</ol>\n" +
|
||||||
|
"";
|
||||||
|
|
||||||
|
final Markwon markwon = Markwon.builder(context)
|
||||||
|
.usePlugin(HtmlPlugin.create())
|
||||||
|
.build();
|
||||||
|
markwon.setMarkdown(textView, md);
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,8 @@ import io.noties.markwon.html.TagHandler;
|
|||||||
|
|
||||||
public class ListHandler extends TagHandler {
|
public class ListHandler extends TagHandler {
|
||||||
|
|
||||||
|
private static final String START_KEY = "start";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(
|
public void handle(
|
||||||
@NonNull MarkwonVisitor visitor,
|
@NonNull MarkwonVisitor visitor,
|
||||||
@ -41,7 +43,7 @@ public class ListHandler extends TagHandler {
|
|||||||
final RenderProps renderProps = visitor.renderProps();
|
final RenderProps renderProps = visitor.renderProps();
|
||||||
final SpanFactory spanFactory = configuration.spansFactory().get(ListItem.class);
|
final SpanFactory spanFactory = configuration.spansFactory().get(ListItem.class);
|
||||||
|
|
||||||
int number = 1;
|
int number = Integer.parseInt(block.attributes().containsKey(START_KEY) ? block.attributes().get(START_KEY) : "1");
|
||||||
final int bulletLevel = currentBulletListLevel(block);
|
final int bulletLevel = currentBulletListLevel(block);
|
||||||
|
|
||||||
for (HtmlTag.Block child : block.children()) {
|
for (HtmlTag.Block child : block.children()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user