Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app-sample/samples.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
"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",
"id": "20210201140501",
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

public class ListHandler extends TagHandler {

private static final String START_KEY = "start";

@Override
public void handle(
@NonNull MarkwonVisitor visitor,
Expand All @@ -41,7 +43,7 @@ public void handle(
final RenderProps renderProps = visitor.renderProps();
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);

for (HtmlTag.Block child : block.children()) {
Expand Down