diff --git a/app/src/main/java/ru/noties/markwon/MarkdownRenderer.java b/app/src/main/java/ru/noties/markwon/MarkdownRenderer.java
index a868bbcd..d8e8a83d 100644
--- a/app/src/main/java/ru/noties/markwon/MarkdownRenderer.java
+++ b/app/src/main/java/ru/noties/markwon/MarkdownRenderer.java
@@ -87,6 +87,8 @@ public class MarkdownRenderer {
0x20000000
);
+ final int red = 0xFFff0000;
+
final SpannableConfiguration configuration = SpannableConfiguration.builder(context)
.asyncDrawableLoader(loader)
.urlProcessor(urlProcessor)
@@ -94,6 +96,7 @@ public class MarkdownRenderer {
.theme(SpannableTheme.builderWithDefaults(context)
.codeBackgroundColor(background)
.codeTextColor(prism4jTheme.textColor())
+ .listItemColor(red)
.build())
.factory(new GifAwareSpannableFactory(gifPlaceholder))
.trimWhiteSpaceEnd(false)
diff --git a/docs/.vuepress/components/Link.vue b/docs/.vuepress/components/Link.vue
index a5cdf9d4..68967153 100644
--- a/docs/.vuepress/components/Link.vue
+++ b/docs/.vuepress/components/Link.vue
@@ -1,5 +1,5 @@
-
+ {{linkText()}}
+
diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js
index 83c81edc..8b763ead 100644
--- a/docs/.vuepress/config.js
+++ b/docs/.vuepress/config.js
@@ -8,15 +8,18 @@ module.exports = {
themeConfig: {
nav: [
{ text: 'Install', link: '/docs/install.md' },
+ { text: 'Changelog', link: '/CHANGELOG.md' },
{ text: 'Github', link: 'https://github.com/noties/Markwon' }
],
sidebar: [
'/',
'/docs/getting-started.md',
'/docs/configure.md',
- '/docs/html.md',
- '/docs/syntax-highlight.md',
+ '/docs/theme.md',
+ '/docs/factory.md',
'/docs/image-loader.md',
+ '/docs/syntax-highlight.md',
+ '/docs/html.md',
'/docs/view.md'
]
}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
new file mode 100644
index 00000000..5ddad421
--- /dev/null
+++ b/docs/CHANGELOG.md
@@ -0,0 +1 @@
+# Changelog
\ No newline at end of file
diff --git a/docs/deploy.sh b/docs/deploy.sh
old mode 100644
new mode 100755
diff --git a/docs/docs/configure.md b/docs/docs/configure.md
index af4abbfe..6ceba05b 100644
--- a/docs/docs/configure.md
+++ b/docs/docs/configure.md
@@ -1 +1,42 @@
-# Configuration
\ No newline at end of file
+# Configuration
+
+factories
+basic info
+there are a lot of options, but using default instance will probably fit the needs (except maybe for image loader)
+
+## Theme
+
+## Images
+
+### Async loader
+
+### Size resolver
+
+## Syntax highlight
+
+Although interface was there initially only starting with {version} there is an implementation
+refer to doc
+
+## Link resolver
+
+Interface to respond to action when a link span is clicked
+
+## URL processor
+
+Interface to pre-process all URLs in a document (assets, relative, absolute)
+
+## Factory
+
+## softBreakAddsNewLine
+issue, reason
+
+## trimWhiteSpaceEnd
+compact mode
+
+## HTML
+
+### Parser
+
+### Renderer
+
+### htmlIgnoreNonClosedTags
diff --git a/docs/docs/factory.md b/docs/docs/factory.md
new file mode 100644
index 00000000..86934fbf
--- /dev/null
+++ b/docs/docs/factory.md
@@ -0,0 +1 @@
+# Factory
\ No newline at end of file
diff --git a/docs/docs/getting-started.md b/docs/docs/getting-started.md
index 3541723b..8319cc2d 100644
--- a/docs/docs/getting-started.md
+++ b/docs/docs/getting-started.md
@@ -1,6 +1,6 @@
# Getting started
:::tip Installation
-Please follow [installation](/docs/install.md) section instructions
+Please follow [installation](/docs/install.md) instructions
to learn how to add `Markwon` to your project
:::
\ No newline at end of file
diff --git a/docs/docs/html.md b/docs/docs/html.md
index f1ac0696..eeedc048 100644
--- a/docs/docs/html.md
+++ b/docs/docs/html.md
@@ -1,12 +1,12 @@
# HTML
-
+
-Starting with version `2.x.x` `Markwon` brings the whole HTML parsing/rendering
+Starting with version `2.0.0` `Markwon` brings the whole HTML parsing/rendering
stack _on-site_. The main reason for this are _special_ definitions of HTML nodes
by . More specifically:
and .
These two are _a bit_ different from _native_ HTML understanding.
-Well, they are completely different and share only the same names as
+Well, they are _completely_ different and share only the same names as
and
elements. This leads to situations when for example an `` tag is considered
a block when it's used like this:
@@ -84,11 +84,89 @@ This might seem like a minor problem, but add more tags to a document,
introduce some deeply nested structures, spice openning and closing tags up
by adding markdown markup between them and finally write _malicious_ HTML code :laughing:!
-Because of this I
+There is no such problem on the _frontend_ for which commonmark specification is mostly
+aimed as _frontend_ runs in a web-browser environment. After all _parsed_ markdown
+will become HTML tags (most common usage). And web-browser will know how to render final result.
-afterall creating an implementation of a web browser is not a purpose of this library.
+We, on the other hand, do not posess HTML heritage (*thank :robot:!*), but still
+want to display some HTML to style resulting markdown a bit. That's why `Markwon`
+incorporated own HTML parsing logic. It is based on the project.
+And makes usage of the `Tokekiser` class that allows to _tokenise_ input HTML.
+All other code that doesn't follow this purpose was removed. It's safe to use
+in projects that already have `jsoup` dependency as `Markwon` repackaged **jsoup** source classes
+(which could be found )
-html-entities
+## Parser
+
+There are no additional steps to configure HTML parsing. It's enabled by default.
+If you wish to _exclude_ it, please follow the [exclude](#exclude-html-parsing) section below.
+
+The key class here is: `MarkwonHtmlParser` that is defined in `markwon-html-parser-api` module.
+`markwon-html-parser-api` is a simple module that defines HTML parsing contract and
+does not provide implementation.
+
+To change what implementation `Markwon` should use, `SpannableConfiguration` can be used:
+
+```java{2}
+SpannableConfiguration.builder(context)
+ .htmlParser(MarkwonHtmlParser)
+ .build();
+```
+
+`markwon-html-parser-impl` on the other hand provides `MarkwonHtmlParser` implementation.
+It's called `MarkwonHtmlParserImpl`. It can be created like this:
+
+```java
+final MarkwonHtmlParser htmlParser = MarkwonHtmlParserImpl.create();
+// or
+final MarkwonHtmlParser htmlParser = MarkwonHtmlParserImpl.create(HtmlEmptyTagReplacement);
+```
+
+### Empty tag replacement
+
+In order to append text content for self-closing, void or just _empty_ HTML tags,
+`HtmlEmptyTagReplacement` can be used. As we cannot set Span for empty content,
+we must represent empty tag with text during parsing stage (if we want it to be represented).
+
+Consider this:
+* ``
+* ` `
+* ``
+
+By default (`HtmlEmptyTagReplacement.create()`) will handle `img` and `br` tags.
+`img` will be replaced with `alt` property if it is present and `\uFFFC` if it is not.
+And `br` will insert a new line.
+
+### Non-closed tags
+
+It's possible that your HTML can contain non-closed tags. By default `Markwon` will ignore them,
+but if you wish to get a bit closer to a web-browser experience, you can allow this behaviour:
+
+```java{2}
+SpannableConfiguration.builder(context)
+ .htmlIgnoreNonClosedTags(false)
+ .build();
+```
+
+:::warning Note
+If there is (for example) an `` tag at the start of a document and it's not closed
+and `Markwon` is configured to **not** ignore non-closed tags (`.htmlIgnoreNonClosedTags(false)`),
+it will make the whole document in italics
+:::
+
+### Implementation note
+
+`MarkwonHtmlParserImpl` does not create a unified HTML node. Instead it creates
+2 collections: inline tags and block tags. Inline tags are represented as a `List`
+of inline tags (). And
+block tags are structured in a tree. This helps to achieve _browser_-like behaviour,
+when open inline tag is applied to all content (even if inside blocks) until closing tag.
+All tags that are not _inline_ are considered to be _block_ ones.
+
+## Renderer
+
+### Custom tag handler
+CssInlineStyleParser
## Exclude HTML parsing
@@ -111,4 +189,11 @@ dependencies {
Excluding `markwon-html-parser-impl` this way will result in
`MarkwonHtmlParser#noOp` implementation. No further steps are
-required.
\ No newline at end of file
+required.
+
+:::warning Note
+Excluding `markwon-html-parser-impl` won't remove *all* the content between
+HTML tags. It will if `commonmark` decides that a specific fragment is a
+`HtmlBlock`, but it won't if fragment is considered a `HtmlInline` as `HtmlInline`
+does not contain contents (just a tag definition).
+:::
\ No newline at end of file
diff --git a/docs/docs/image-loader.md b/docs/docs/image-loader.md
index 331e0ea3..d14d0008 100644
--- a/docs/docs/image-loader.md
+++ b/docs/docs/image-loader.md
@@ -1 +1 @@
-# Image loader
\ No newline at end of file
+# Images
\ No newline at end of file
diff --git a/docs/docs/install.md b/docs/docs/install.md
index 23c957a3..caa3684f 100644
--- a/docs/docs/install.md
+++ b/docs/docs/install.md
@@ -5,6 +5,10 @@ next: /docs/getting-started.md
# Installation
+
+
+proguard when using image-loader
+
## Snapshot

diff --git a/docs/docs/theme.md b/docs/docs/theme.md
new file mode 100644
index 00000000..e48261d4
--- /dev/null
+++ b/docs/docs/theme.md
@@ -0,0 +1,50 @@
+# Theme
+
+Here is the list of properties that can be configured via `SpannableTheme#builder` factory
+method. If you wish to control what is out of this list, you can use [SpannableFactory](/docs/factory.md)
+abstraction which lets you to gather full control of Spans that are used to display markdown.
+
+## Link color
+
+Controls the color of a [link](#)
+
+
+
+* `TextPaint#linkColor` will be used to determine linkColor of a context
+
+## Block margin
+
+Starting margin before text content for the:
+* lists
+* blockquotes
+* task lists
+
+
+
+## Block quote
+
+Customizations for the `blockquote` stripe
+
+> Quote
+
+### Stripe width
+
+Width of a blockquote stripe
+
+
+
+### Stripe color
+
+Color of a blockquote stripe
+
+
+
+## List
+
+### List item color
+
+Controls the color of a list item. For ordered list: leading number,
+for unordered list: bullet.
+
+* UL
+1. OL
\ No newline at end of file
diff --git a/docs/docs/view.md b/docs/docs/view.md
index b19a80fb..3bc5f982 100644
--- a/docs/docs/view.md
+++ b/docs/docs/view.md
@@ -1 +1 @@
-# View
\ No newline at end of file
+# MarkwonView
diff --git a/markwon/src/main/java/ru/noties/markwon/spans/OrderedListItemSpan.java b/markwon/src/main/java/ru/noties/markwon/spans/OrderedListItemSpan.java
index 16e9895f..29f68e9e 100644
--- a/markwon/src/main/java/ru/noties/markwon/spans/OrderedListItemSpan.java
+++ b/markwon/src/main/java/ru/noties/markwon/spans/OrderedListItemSpan.java
@@ -10,6 +10,7 @@ public class OrderedListItemSpan implements LeadingMarginSpan {
private final SpannableTheme theme;
private final String number;
+ private final Paint paint = ObjectsPool.paint();
// we will use this variable to check if our order number text exceeds block margin,
// so we will use it instead of block margin
@@ -39,7 +40,9 @@ public class OrderedListItemSpan implements LeadingMarginSpan {
return;
}
- theme.applyListItemStyle(p);
+ paint.set(p);
+
+ theme.applyListItemStyle(paint);
final int numberWidth = (int) (p.measureText(number) + .5F);
@@ -60,6 +63,6 @@ public class OrderedListItemSpan implements LeadingMarginSpan {
}
// @since 1.1.1 we are using `baseline` argument to position text
- c.drawText(number, left, baseline, p);
+ c.drawText(number, left, baseline, paint);
}
}