From 8fb15b77a1ebf4fbc62ce223ae1e2ee20cf90c10 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Wed, 22 Aug 2018 12:26:52 +0300 Subject: [PATCH] Remove old docs --- docs-old/AsyncDrawableLoader.md | 54 ------- docs-old/HtmlParser.md | 60 -------- docs-old/LinkResolver.md | 28 ---- docs-old/SpannableConfiguration.md | 43 ------ docs-old/SpannableTheme.md | 136 ------------------ docs-old/SyntaxHighlight.md | 37 ----- docs-old/UrlProcessor.md | 40 ------ docs/README.md | 2 +- docs/docs/syntax-highlight.md | 4 +- .../ru/noties/markwon/html/api/HtmlTag.java | 6 + .../html/api/MarkwonHtmlParserNoOp.java | 6 +- 11 files changed, 14 insertions(+), 402 deletions(-) delete mode 100644 docs-old/AsyncDrawableLoader.md delete mode 100644 docs-old/HtmlParser.md delete mode 100644 docs-old/LinkResolver.md delete mode 100644 docs-old/SpannableConfiguration.md delete mode 100644 docs-old/SpannableTheme.md delete mode 100644 docs-old/SyntaxHighlight.md delete mode 100644 docs-old/UrlProcessor.md diff --git a/docs-old/AsyncDrawableLoader.md b/docs-old/AsyncDrawableLoader.md deleted file mode 100644 index dc7c5db2..00000000 --- a/docs-old/AsyncDrawableLoader.md +++ /dev/null @@ -1,54 +0,0 @@ -# AsyncDrawable.Loader - -By default this library does not render any of the images. It's done to simplify rendering of text-based markdown. But if images must be supported, then the `AsyncDrawable.Loader` can be specified whilst building a `SpannableConfiguration` instance: - -```java -final AsyncDrawable.Loader loader = new AsyncDrawable.Loader() { - @Override - public void load(@NonNull String destination, @NonNull final AsyncDrawable drawable) { - // `download` method is here for demonstration purposes, it's not included in this interface - download(destination, new Callback() { - @Override - public void onDownloaded(Drawable d) { - // additionally we can call `drawable.isAttached()` - // to ensure if AsyncDrawable is in layout - drawable.setResult(d); - } - }); - } - - @Override - public void cancel(@NonNull String destination) { - // cancel download here - } -}; - -// `this` here referrs to a Context instance -final SpannableConfiguration configuration = SpannableConfiguration.builder(this) - .asyncDrawableLoader(loader) - .build(); -``` - -There is also standalone artifact that supports image loading *out-of-box* (including support for **SVG** & **GIF**), but provides little to none configuration and could be somewhat not optimal. Please refer to the [README][mil-readme] of the module. - - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md - -[mil-readme]: ../library-image-loader/README.md diff --git a/docs-old/HtmlParser.md b/docs-old/HtmlParser.md deleted file mode 100644 index 01f545fe..00000000 --- a/docs-old/HtmlParser.md +++ /dev/null @@ -1,60 +0,0 @@ -# HtmlParser - -As markdown supports HTML to be inlined, we need to introduce another entity that does (limited) parsing. Obtain an instance of `SpannableHtmlParser` via one of these factory methods: - -```java -SpannableHtmlParser.create(SpannableTheme, AsyncDrawable.Loader) -SpannableHtmlParser.create(SpannableTheme, AsyncDrawable.Loader, UrlProcessor, LinkSpan.Resolver) -``` - -Or, if further tweaking is requered builder methods: -```java -// creates empty builder -SpannableHtmlParser.builder(); - -// creates builder that is set-up to default values -SpannableHtmlParser.builderWithDefaults( - @NonNull SpannableTheme theme, - @Nullable AsyncDrawable.Loader asyncDrawableLoader, - @Nullable UrlProcessor urlProcessor, - @Nullable LinkSpan.Resolver resolver -) -``` - -Builder with defaults additionally handles these HTML tags: -* `b`, `strong` -* `i`, `em`, `cite`, `dfn` -* `sup` -* `sub` -* `u` -* `del`, `s`, `strike` -* `a` -* `img` (only if `AsyncDrawable.Loader` was provided) - -You can add own simple tags handling (or override default) via: -```java -SpannableHtmlParser.Builder.simpleTag(String, SpanProvider) -``` - -Please note, that not all tags are possible to handle via this. These are so called `void` tags ([link](https://www.w3.org/TR/html51/syntax.html#void-elements)) and so-called `html-blocks` ([link](http://spec.commonmark.org/0.18/#html-blocks)). An exception is made only for `img` tag -> it's possible to handle it via `imageProvider` property in `Builder` - - - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md \ No newline at end of file diff --git a/docs-old/LinkResolver.md b/docs-old/LinkResolver.md deleted file mode 100644 index 67c14f85..00000000 --- a/docs-old/LinkResolver.md +++ /dev/null @@ -1,28 +0,0 @@ -# LinkResolver - -Link resolver is used to navigate to clicked link. By default `LinkResolverDef` is used and it just constructs an `Intent` and launches activity that can handle it, or silently fails if activity cannot be resolved. The main interface: -```java -public interface Resolver { - void resolve(View view, @NonNull String link); -} -``` - - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md \ No newline at end of file diff --git a/docs-old/SpannableConfiguration.md b/docs-old/SpannableConfiguration.md deleted file mode 100644 index d8b3bfee..00000000 --- a/docs-old/SpannableConfiguration.md +++ /dev/null @@ -1,43 +0,0 @@ -# SpannableConfiguration - -In order to render correctly markdown, this library needs a `SpannableConfiguration` instance. It has 2 factory methods: - -```java -// creates default instance -SpannableConfiguration.create(Context); - -// returns configurable Builder -SpannableConfiguration.builder(Context); -``` - -`SpannableConfiguration.Builder` class has these configurable properties (which are described in more detail further): -```java -public Builder theme(SpannableTheme theme); -public Builder asyncDrawableLoader(AsyncDrawable.Loader asyncDrawableLoader); -public Builder syntaxHighlight(SyntaxHighlight syntaxHighlight); -public Builder linkResolver(LinkSpan.Resolver linkResolver); -public Builder urlProcessor(UrlProcessor urlProcessor); -public Builder htmlParser(SpannableHtmlParser htmlParser); - -// and obviously: -public SpannableConfiguration build(); -``` - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md \ No newline at end of file diff --git a/docs-old/SpannableTheme.md b/docs-old/SpannableTheme.md deleted file mode 100644 index b4fd7dee..00000000 --- a/docs-old/SpannableTheme.md +++ /dev/null @@ -1,136 +0,0 @@ -# SpannableTheme - -`SpannableTheme` controls the appearance of rendered markdown. It has pretty reasonable defaults, which are established based on style of a TextView to which it is applied. It has some factory methods: -```java -// creates ready-to-use SpannableThemeObject -SpannableTheme.create(Context); - -// can be used to tweak default appearance -SpannableTheme.builderWithDefaults(Context); - -// returns empty builder (no default values are set) -SpannableTheme.builder(); - -// returns a builder that is instantiated with all values from specified SpannableTheme -SpannableTheme.builder(SpannableTheme copyFrom); -``` - -`SpannableTheme.Builder` have these configurations: -#### Link -```java -public Builder linkColor(@ColorInt int linkColor); -``` - -#### Block -```java -// left margin for: lists & quotes (text is shifted) -public Builder blockMargin(@Dimension int blockMargin); -``` - -#### Quote -```java -// width of quote indication (the `|`) -public Builder blockQuoteWidth(@Dimension int blockQuoteWidth); - -// color of `|` quote indication -public Builder blockQuoteColor(@ColorInt int blockQuoteColor); -``` - -#### Lists -```java -// color of list item bullets(●, ○, ■)/numbers -public Builder listItemColor(@ColorInt int listItemColor); - -// stroke width for list bullet (2nd level - `○`) -public Builder bulletListItemStrokeWidth(@Dimension int bulletListItemStrokeWidth); - -// width of list bullet (●, ○, ■) -public Builder bulletWidth(@Dimension int bulletWidth); -``` - -#### Code -```java -// text color for `code` blocks -public Builder codeTextColor(@ColorInt int codeTextColor); - -// background color for `code` blocks -public Builder codeBackgroundColor(@ColorInt int codeBackgroundColor); - -// left margin for multiline `code` blocks -public Builder codeMultilineMargin(@Dimension int codeMultilineMargin); - -// typeface of `code` block -public Builder codeTypeface(@NonNull Typeface codeTypeface); - -// text size for `code` block -public Builder codeTextSize(@Dimension int codeTextSize); -``` - -#### Headings -```java -// height of the `break` line under h1 & h2 -public Builder headingBreakHeight(@Dimension int headingBreakHeight); - -// color of the `break` line under h1 & h2 -public Builder headingBreakColor(@ColorInt int headingBreakColor); -``` - -#### SuperScript & SupScript -```java -// ratio for & text size (calculated based on TextView text size) -public Builder scriptTextSizeRatio(@FloatRange(from = .0F, to = Float.MAX_VALUE) float scriptTextSizeRatio); -``` - -#### Thematic break -```java -// the `---` thematic break color -public Builder thematicBreakColor(@ColorInt int thematicBreakColor); - -// the `---` thematic break height -public Builder thematicBreakHeight(@Dimension int thematicBreakHeight); -``` - -#### Tables -```java -// padding inside a table cell -public Builder tableCellPadding(@Dimension int tableCellPadding); - -// color of table borders -public Builder tableBorderColor(@ColorInt int tableBorderColor); - -// the `stroke` width of table border -public Builder tableBorderWidth(@Dimension int tableBorderWidth); - -// the background of odd table rows -public Builder tableOddRowBackgroundColor(@ColorInt int tableOddRowBackgroundColor); -``` - -#### Task lists - -Task lists are supported but with some limitations. First of all, task list cannot be nested -(in a list, quote, etc). By default (if used factory method `builderWithDefaults`) TaskListDrawable -will be used with `linkColor` as the primary color and `windowBackground` as the checkMarkColor. - -```java -public Builder taskListDrawable(@NonNull Drawable taskListDrawable); -``` - - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md \ No newline at end of file diff --git a/docs-old/SyntaxHighlight.md b/docs-old/SyntaxHighlight.md deleted file mode 100644 index 86f85731..00000000 --- a/docs-old/SyntaxHighlight.md +++ /dev/null @@ -1,37 +0,0 @@ -# Syntax highlight - -This library does not provide ready-to-be-used implementation of syntax highlight, but it can be added via `SyntaxHighlight` interface whilst building `SpannableConfiguration`: - -```java -final SyntaxHighlight syntaxHighlight = new SyntaxHighlight() { - @NonNull - @Override - public CharSequence highlight(@Nullable String info, @NonNull String code) { - // create Spanned of highlight here - return null; // must not return `null` here - } -}; - -final SpannableConfiguration configuration = SpannableConfiguration.builder(this) - .syntaxHighlight(syntaxHighlight) - .build(); -``` - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md \ No newline at end of file diff --git a/docs-old/UrlProcessor.md b/docs-old/UrlProcessor.md deleted file mode 100644 index 6a8f7dc4..00000000 --- a/docs-old/UrlProcessor.md +++ /dev/null @@ -1,40 +0,0 @@ -# UrlProcessor - -If you wish to process urls (links & images) that markdown contains, the `UrlProcessor` can be used: -```java -final UrlProcessor urlProcessor = new UrlProcessor() { - @NonNull - @Override - public String process(@NonNull String destination) { - // modify the `destination` or return as-is - return null; - } -}; - -final SpannableConfiguration configuration = SpannableConfiguration.builder(this) - .urlProcessor(urlProcessor) - .build(); -``` -The primary goal of additing this abstraction is to give ability to convert relative urls to absolute ones. If it fits your purpose, then `UrlProcessorRelativeToAbsolute` can be used: -```java -final UrlProcessor urlProcessor = new UrlProcessorRelativeToAbsolute("https://this-is-base.org"); -``` - -### Contents - -* [SpannableConfiguration] -* * [SpannableTheme] -* * [AsyncDrawableLoader] -* * [SyntaxHighlight] -* * [LinkResolver] -* * [UrlProcessor] -* * [HtmlParser] - - -[SpannableConfiguration]: ./SpannableConfiguration.md -[SpannableTheme]: ./SpannableTheme.md -[AsyncDrawableLoader]: ./AsyncDrawableLoader.md -[SyntaxHighlight]: ./SyntaxHighlight.md -[LinkResolver]: ./LinkResolver.md -[UrlProcessor]: ./UrlProcessor.md -[HtmlParser]: ./HtmlParser.md \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index f3b6a87b..cb2be873 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,7 +17,7 @@ It gives ability to display markdown in all TextView widgets (**TextView**, **Button**, **Switch**, **CheckBox**, etc), **Toasts** and all other places that accept **Spanned content**. Library provides reasonable defaults to display style of a markdown content but also gives all the means to tweak the appearance if desired. All markdown features -listed in [commonmark spec] are supported (including support for **inlined/block HTML code**, +listed in are supported (including support for **inlined/block HTML code**, **markdown tables**, **images** and **syntax highlight**). ## Supported markdown features: diff --git a/docs/docs/syntax-highlight.md b/docs/docs/syntax-highlight.md index c8044f3d..64454903 100644 --- a/docs/docs/syntax-highlight.md +++ b/docs/docs/syntax-highlight.md @@ -64,4 +64,6 @@ public interface Prism4jTheme { } ``` -> You can extend `Prism4jThemeBase` which has some helper methods \ No newline at end of file +:::tip +You can extend `Prism4jThemeBase` which has some helper methods +::: \ No newline at end of file diff --git a/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/HtmlTag.java b/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/HtmlTag.java index 8cd92993..f3245876 100644 --- a/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/HtmlTag.java +++ b/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/HtmlTag.java @@ -45,8 +45,14 @@ public interface HtmlTag { @NonNull Map attributes(); + /** + * @see Inline + */ boolean isInline(); + /** + * @see Block + */ boolean isBlock(); @NonNull diff --git a/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/MarkwonHtmlParserNoOp.java b/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/MarkwonHtmlParserNoOp.java index f50a8941..0a024865 100644 --- a/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/MarkwonHtmlParserNoOp.java +++ b/markwon-html-parser-api/src/main/java/ru/noties/markwon/html/api/MarkwonHtmlParserNoOp.java @@ -2,6 +2,8 @@ package ru.noties.markwon.html.api; import android.support.annotation.NonNull; +import java.util.Collections; + /** * @see MarkwonHtmlParser * @since 2.0.0 @@ -15,12 +17,12 @@ class MarkwonHtmlParserNoOp extends MarkwonHtmlParser { @Override public void flushInlineTags(int documentLength, @NonNull FlushAction action) { - + action.apply(Collections.emptyList()); } @Override public void flushBlockTags(int documentLength, @NonNull FlushAction action) { - + action.apply(Collections.emptyList()); } @Override