+
+
+
+
+
diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js
index ab5c22d5..c465c245 100644
--- a/docs/.vuepress/config.js
+++ b/docs/.vuepress/config.js
@@ -3,11 +3,11 @@ module.exports = {
title: 'Markwon',
description: 'Android markdown library based on commonmark specification',
head: [
- ['link', {rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png?v=1'}],
- ['link', {rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png?v=1'}],
- ['link', {rel: 'icon', href: '/favicon.ico?v=1'}],
- ['link', {rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png?v=1'}],
- ['link', {rel: 'manifest', href: '/manifest.json?v=1'}],
+ ['link', { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png?v=1' }],
+ ['link', { rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png?v=1' }],
+ ['link', { rel: 'icon', href: '/favicon.ico?v=1' }],
+ ['link', { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png?v=1' }],
+ ['link', { rel: 'manifest', href: '/manifest.json?v=1' }],
],
themeConfig: {
nav: [
@@ -16,67 +16,51 @@ module.exports = {
{ text: 'Sandbox', link: '/sandbox.md' },
{ text: 'Github', link: 'https://github.com/noties/Markwon' }
],
- sidebar: [
- '/',
- {
- title: 'Core',
- children: [
- '/docs/core/getting-started.md'
- ]
- },
- {
- title: 'LaTeX extension',
- children: [
- '/docs/ext-latex/latex.md'
- ]
- },
- {
- title: 'Strikethrough extension',
- children: [
- '/docs/ext-strikethrough/strikethrough.md'
- ]
- },
- {
- title: 'Tables extension',
- children: [
- '/docs/ext-tables/tables.md'
- ]
- },
- {
- title: 'Task list extension',
- children: [
- '/docs/ext-tasklist/tasklist.md'
- ]
- },
- {
- title: 'HTML',
- children: [
- '/docs/html/html.md'
- ]
- },
- {
- title: 'Image',
- children: [
- '/docs/image/gif.md',
- '/docs/image/okhttp.md',
- '/docs/image/svg.md'
- ]
- },
- {
- title: 'Recycler',
- children: [
- '/docs/recycler/recycler.md'
- ]
- },
- {
- title: 'Syntax highlight',
- children: [
- '/docs/syntax-highlight/syntax-highlight.md'
- ]
- },
- '/docs/migration-2-3.md'
-
- ],
+ sidebar: {
+ '/docs/v2/': [
+ 'install.md',
+ 'getting-started.md',
+ 'configure.md',
+ 'theme.md',
+ 'factory.md',
+ 'image-loader.md',
+ 'syntax-highlight.md',
+ 'html.md',
+ 'view.md'
+ ],
+ '/': [
+ '',
+ {
+ title: 'Core',
+ children: [
+ '/docs/core/getting-started.md',
+ '/docs/core/theme.md'
+ ]
+ },
+ '/docs/ext-latex/latex.md',
+ '/docs/ext-strikethrough/strikethrough.md',
+ '/docs/ext-tables/tables.md',
+ '/docs/ext-tasklist/tasklist.md',
+ {
+ title: 'HTML',
+ children: [
+ '/docs/html/html.md'
+ ]
+ },
+ {
+ title: 'Image',
+ children: [
+ '/docs/image/gif.md',
+ '/docs/image/okhttp.md',
+ '/docs/image/svg.md'
+ ]
+ },
+ '/docs/recycler/recycler.md',
+ '/docs/syntax-highlight/syntax-highlight.md',
+ '/docs/migration-2-3.md',
+ ['/docs/v2/install.md', 'Legacy 2.x.x documentation']
+ ]
+ },
sidebarDepth: 2,
lastUpdated: true
},
diff --git a/docs/docs/core/theme.md b/docs/docs/core/theme.md
new file mode 100644
index 00000000..b904fbbe
--- /dev/null
+++ b/docs/docs/core/theme.md
@@ -0,0 +1,158 @@
+# Theme
+
+Here is the list of properties that can be configured via `MarkwonTheme.Builder` class.
+
+## 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
+
+
+
+### Bullet item stroke width
+
+Border width of a bullet list item (level 2)
+
+* First
+* * Second
+* * * Third
+
+
+
+### Bullet width
+
+The width of the bullet item
+
+* First
+ * Second
+ * Third
+
+
+
+## Code
+
+### Inline code text color
+
+The color of the `code` content
+
+
+
+### Inline code background color
+
+The color of `background` of a code content
+
+
+
+### Block code text color
+
+```
+The color of code block text
+```
+
+
+
+### Block code background color
+
+```
+The color of background of code block text
+```
+
+
+
+### Block code leading margin
+
+Leading margin for the block code content
+
+
+
+### Code typeface
+
+Typeface of code content
+
+
+
+### Code text size
+
+Text size of code content
+
+
+
+## Heading
+
+### Break height
+
+The height of a brake under H1 & H2
+
+
+
+### Break color
+
+The color of a brake under H1 & H2
+
+
+
+### Typeface
+
+The typeface of heading elements
+
+
+
+### Text size
+
+Array of heading text sizes _ratio_ that is applied to text size
+
+
+
+## Thematic break
+
+### Color
+
+Color of a thematic break
+
+
+
+### Height
+
+Height of a thematic break
+
+
diff --git a/docs/docs/ext-latex/latex.md b/docs/docs/ext-latex/latex.md
index d0922cf8..8fa856fc 100644
--- a/docs/docs/ext-latex/latex.md
+++ b/docs/docs/ext-latex/latex.md
@@ -1,7 +1,46 @@
----
-title: 'Overview'
----
-
# LaTeX extension
-
\ No newline at end of file
+
+
+This is an extension that will help you display LaTeX formulas in your markdown.
+Syntax is pretty simple: pre-fix and post-fix your latex with `$$` (double dollar sign).
+`$$` should be the first characters in a line.
+
+```markdown
+$$
+\\text{A long division \\longdiv{12345}{13}
+$$
+```
+
+```markdown
+$$\\text{A long division \\longdiv{12345}{13}$$
+```
+
+```java
+Markwon.builder(context)
+ .use(ImagesPlugin.create(context))
+ .use(JLatexMathPlugin.create(new Config(textSize))
+ .build();
+```
+
+This extension uses [jlatexmath-android](https://github.com/noties/jlatexmath-android) artifact to create LaTeX drawable. Then it
+registers special `latex` image scheme handler and uses `AsyncDrawableLoader` to display
+final result
+
+## Config
+
+```java
+public static class Config {
+
+ protected final float textSize;
+
+ protected Drawable background;
+
+ @JLatexMathDrawable.Align
+ protected int align = JLatexMathDrawable.ALIGN_CENTER;
+
+ protected boolean fitCanvas = true;
+
+ protected int padding;
+}
+```
diff --git a/docs/docs/ext-strikethrough/strikethrough.md b/docs/docs/ext-strikethrough/strikethrough.md
index ca78dfaa..9bbfc0e5 100644
--- a/docs/docs/ext-strikethrough/strikethrough.md
+++ b/docs/docs/ext-strikethrough/strikethrough.md
@@ -1,7 +1,29 @@
----
-title: 'Overview'
----
-
# Strikethrough extension
-
\ No newline at end of file
+
+
+This module adds `strikethrough` functionality to `Markwon` via `StrikethroughPlugin`:
+
+```java
+Markwon.builder(context)
+ .usePlugin(StrikethroughPlugin.create())
+```
+
+This plugin registers `SpanFactory` for `Strikethrough` node, so it's possible to customize Strikethrough Span that is used in rendering:
+
+```java
+Markwon.builder(context)
+ .usePlugin(StrikethroughPlugin.create())
+ .usePlugin(new AbstractMarkwonPlugin() {
+ @Override
+ public void configureSpansFactory(@NonNull MarkwonSpansFactory.Builder builder) {
+ builder.setFactory(Strikethrough.class, new SpanFactory() {
+ @Override
+ public Object getSpans(@NonNull MarkwonConfiguration configuration, @NonNull RenderProps props) {
+ // will use Underline span instead of Strikethrough
+ return new UnderlineSpan();
+ }
+ });
+ }
+ })
+```
diff --git a/docs/docs/ext-tables/tables.md b/docs/docs/ext-tables/tables.md
index c8aa89d1..afa534ff 100644
--- a/docs/docs/ext-tables/tables.md
+++ b/docs/docs/ext-tables/tables.md
@@ -1,7 +1,83 @@
----
-title: 'Overview'
----
-
# Tables extension
-
\ No newline at end of file
+
+
+This extension adds support for GFM tables.
+
+```java
+final Markwon markwon = Markwon.builder(context)
+ // create default instance of TablePlugin
+ .usePlugin(TablePlugin.create(context))
+```
+
+```java
+final TableTheme tableTheme = TableTheme.builder()
+ .tableBorderColor(Color.RED)
+ .tableBorderWidth(0)
+ .tableCellPadding(0)
+ .tableHeaderRowBackgroundColor(Color.BLACK)
+ .tableEvenRowBackgroundColor(Color.GREEN)
+ .tableOddRowBackgroundColor(Color.YELLOW)
+ .build();
+
+final Markwon markwon = Markwon.builder(context)
+ .usePlugin(TablePlugin.create(tableTheme))
+```
+
+Please note, that _by default_ tables have limitations. For example, there is no support
+for images inside table cells. And table contents won't be copied to clipboard if a TextView
+has such functionality. Table will always take full width of a TextView in which it is displayed.
+All columns will always be the of the same width. So, _default_ implementation provides basic
+functionality which can answer some needs. These all come from the limited nature of the TextView
+to display such content.
+
+In order to provide full-fledged experience, tables must be displayed in a special widget.
+Since version `3.0.0` Markwon provides a special artifact `markwon-recycler` that allows
+to render markdown in a set of widgets in a RecyclerView. It also gives ability to change
+display widget form TextView to any other.
+
+```java
+final Table table = Table.parse(Markwon, TableBlock);
+myTableWidget.setTable(table);
+```
+
+Unfortunately Markwon does not provide a widget that can be used for tables. But it does
+provide API that can be used to achieve desired result.
+
+## Theme
+
+### Cell padding
+
+Padding inside a table cell
+
+
+
+### Border color
+
+The color of table borders
+
+
+
+### Border width
+
+The width of table borders
+
+
+
+### Odd row background
+
+Background of an odd table row
+
+
+
+### Even row background
+
+Background of an even table row
+
+
+
+### Header row background
+
+Background of header table row
+
+
diff --git a/docs/docs/ext-tasklist/tasklist.md b/docs/docs/ext-tasklist/tasklist.md
index 0ff1603e..a955500a 100644
--- a/docs/docs/ext-tasklist/tasklist.md
+++ b/docs/docs/ext-tasklist/tasklist.md
@@ -1,7 +1,3 @@
----
-title: 'Overview'
----
-
# Task list extension
\ No newline at end of file
diff --git a/docs/docs/migration-2-3.md b/docs/docs/migration-2-3.md
index 9a2e5dcc..c7543794 100644
--- a/docs/docs/migration-2-3.md
+++ b/docs/docs/migration-2-3.md
@@ -1 +1 @@
-# Migration v2 -> v3
\ No newline at end of file
+# Migration 2.x.x -> 3.x.x
\ No newline at end of file
diff --git a/docs/docs/recycler/recycler.md b/docs/docs/recycler/recycler.md
index 3c9188a8..1941f4ae 100644
--- a/docs/docs/recycler/recycler.md
+++ b/docs/docs/recycler/recycler.md
@@ -1,7 +1,3 @@
----
-title: 'Overview'
----
-
# Recycler
\ No newline at end of file
diff --git a/docs/docs/syntax-highlight/syntax-highlight.md b/docs/docs/syntax-highlight/syntax-highlight.md
index beec2993..a5203cf6 100644
--- a/docs/docs/syntax-highlight/syntax-highlight.md
+++ b/docs/docs/syntax-highlight/syntax-highlight.md
@@ -1,7 +1,69 @@
----
-title: 'Overview'
----
-
# Syntax highlight
-
\ No newline at end of file
+
+
+This is a simple module to add **syntax highlight** functionality to your markdown rendered with `Markwon` library. It is based on [Prism4j](https://github.com/noties/Prism4j) so lead there to understand how to configure `Prism4j` instance.
+
+
+
+
+
+
+---
+
+First, we need to obtain an instance of `Prism4jSyntaxHighlight` which implements Markwon's `SyntaxHighlight`:
+
+```java
+final SyntaxHighlight highlight =
+ Prism4jSyntaxHighlight.create(Prism4j, Prism4jTheme);
+```
+
+we also can obtain an instance of `Prism4jSyntaxHighlight` that has a _fallback_ option (if a language is not defined in `Prism4j` instance, fallback language can be used):
+
+```java
+final SyntaxHighlight highlight =
+ Prism4jSyntaxHighlight.create(Prism4j, Prism4jTheme, String);
+```
+
+Generally obtaining a `Prism4j` instance is pretty easy:
+
+```java
+final Prism4j prism4j = new Prism4j(new GrammarLocatorDef());
+```
+
+Where `GrammarLocatorDef` is a generated grammar locator (if you use `prism4j-bundler` annotation processor)
+
+`Prism4jTheme` is a specific type that is defined in this module (`prism4j` doesn't know anything about rendering). It has 2 implementations:
+
+* `Prism4jThemeDefault`
+* `Prism4jThemeDarkula`
+
+Both of them can be obtained via factory method `create`:
+
+* `Prism4jThemeDefault.create()`
+* `Prism4jThemeDarkula.create()`
+
+But of cause nothing is stopping you from defining your own theme:
+
+```java
+public interface Prism4jTheme {
+
+ @ColorInt
+ int background();
+
+ @ColorInt
+ int textColor();
+
+ void apply(
+ @NonNull String language,
+ @NonNull Prism4j.Syntax syntax,
+ @NonNull SpannableStringBuilder builder,
+ int start,
+ int end
+ );
+}
+```
+
+:::tip
+You can extend `Prism4jThemeBase` which has some helper methods
+:::
\ No newline at end of file
diff --git a/docs/docs/v2/configure.md b/docs/docs/v2/configure.md
new file mode 100644
index 00000000..c8274988
--- /dev/null
+++ b/docs/docs/v2/configure.md
@@ -0,0 +1,228 @@
+
+
+# Configuration
+
+`SpannableConfiguration` is the core component that controls how markdown is parsed and rendered.
+It can be obtained via factory methods:
+
+```java
+// creates default implementation
+final SpannableConfiguration configuration = SpannableConfiguration.create(context);
+```
+
+```java
+// creates configurablable instance via `#builder` method
+final SpannableConfiguration configuration = SpannableConfiguration.builder(context)
+ .asyncDrawableLoader(AsyncDrawableLoader.create())
+ .build();
+```
+
+:::tip Note
+If `#builder` factory method is used, you do not need to specify default
+values as they will be applied automatically
+:::
+
+:::warning Images
+If you plan on using images inside your markdown/HTML, you will have to **explicitly**
+register an implementation of `AsyncDrawable.Loader` via `#asyncDrawableLoader` builder method.
+`Markwon` comes with ready implementation for that and it can be found in
+`markwon-image-loader` module. Refer to module [documentation](/docs/v2/image-loader.md)
+:::
+
+## Theme
+
+`SpannableTheme` controls how markdown is rendered. It has pretty extensive number of
+options that can be found [here](/docs/v2/theme.md)
+
+```java
+SpannableConfiguration.builder(context)
+ .theme(SpannableTheme)
+ .build();
+```
+
+If `SpannableTheme` is not provided explicitly, `SpannableTheme.create(context)` will be used
+
+## Images
+
+### Async loader
+
+`AsyncDrawable.Loader` handles images in your markdown and HTML
+
+```java
+SpannableConfiguration.builder(context)
+ .asyncDrawableLoader(AsyncDrawable.Loader)
+ .build();
+```
+
+If `AsyncDrawable.Loader` is not provided explicitly, default **no-op** implementation will be used.
+
+:::tip Implementation
+There are no restrictions on what implementation to use, but `Markwon` has artifact that can
+answer the most common needs of displaying SVG, GIF and other image formats. It can be found [here](/docs/v2/image-loader.md)
+:::
+
+### Size resolver
+
+`ImageSizeResolver` controls the size of an image to be displayed. Currently it
+handles only HTML images (specified via `img` tag).
+
+```java
+SpannableConfiguration.builder(context)
+ .imageSizeResolver(ImageSizeResolver)
+ .build();
+```
+
+If not provided explicitly, default `ImageSizeResolverDef` implementation will be used.
+It handles 3 dimention units:
+* `%` (percent)
+* `em` (relative to text size)
+* `px` (absolute size, every dimention that is not `%` or `em` is considered to be _absolute_)
+
+```html
+
+
+
+```
+
+`ImageSizeResolverDef` keeps the ratio of original image if one of the dimentions is missing.
+
+:::warning Height%
+There is no support for `%` units for `height` dimention. This is due to the fact that
+height of an TextView in which markdown is displayed is non-stable and changes with time
+(for example when image is loaded and applied to a TextView it will _increase_ TextView's height),
+so we will have no point-of-refence from which to _calculate_ image height.
+:::
+
+## Syntax highlight
+
+`SyntaxHighlight` controls the syntax highlight for code blocks (in markdown).
+
+```java
+SpannableConfiguration.builder(context)
+ .syntaxHighlight(SyntaxHighlight)
+ .build();
+```
+
+If not provided explicitly, default **no-op** implementation will be used.
+
+:::tip Syntax highlight
+Although `SyntaxHighlight` interface was included with the very first version
+of `Markwon` there were no ready-to-use implementations. But starting with
+`Markwon` provides one. It can be found in `markwon-syntax-highlight` artifact. Refer
+to module [documentation](/docs/v2/syntax-highlight.md)
+:::
+
+## Link resolver
+
+`LinkSpan.Resolver` is triggered when a link is clicked in markdown/HTML.
+
+```java
+SpannableConfiguration.builder(context)
+ .linkResolver(LinkSpan.Resolver)
+ .build();
+```
+
+If not provided explicitly, default `LinkResolverDef` implementation will be used.
+Underneath it constructs an `Intent` and _tries_ to start an Activity associated with it.
+It no Activity is found, it will silently fail (no runtime exceptions)
+
+## URL processor
+
+`UrlProcessor` is used to process found URLs in markdown/HTML.
+
+```java
+SpannableConfiguration.builder(context)
+ .urlProcessor(UrlProcessor)
+ .build();
+```
+
+If not provided explicitly, default **no-op** implementation will be used.
+
+`Markwon` provides 2 implementations of `UrlProcessor`:
+* `UrlProcessorRelativeToAbsolute`
+* `UrlProcessorAndroidAssets`
+
+### UrlProcessorRelativeToAbsolute
+
+`UrlProcessorRelativeToAbsolute` can be used to make relative URL absolute. For example if an image is
+defined like this: `` and `UrlProcessorRelativeToAbsolute`
+is created with `https://github.com/noties/Markwon/raw/master/` as the base:
+`new UrlProcessorRelativeToAbsolute("https://github.com/noties/Markwon/raw/master/")`,
+then final image will have `https://github.com/noties/Markwon/raw/master/art/image.JPG`
+as the destination.
+
+### UrlProcessorAndroidAssets
+
+`UrlProcessorAndroidAssets` can be used to make processed links to point to Android assets folder.
+So an image: `` will have `file:///android_asset/art/image.JPG` as the
+destination
+
+## Factory
+
+`SpannableFactory` is used to control _what_ span implementations to be used
+
+```java
+SpannableConfiguration.builder(context)
+ .factory(SpannableFactory)
+ .build();
+```
+
+If not provided explicitly, default `SpannableFactoryDef` implementation will be used. It is documented
+in [this section](/docs/v2/factory.md)
+
+## Soft line break
+
+`softBreakAddsNewLine` option controls how _soft breaks_ are treated in the final result.
+If `true` -> soft break will add a new line, else it will add a ` ` (space) char.
+
+```java
+SpannableConfiguration.builder(context)
+ .softBreakAddsNewLine(boolean)
+ .build();
+```
+
+If not provided explicitly, default `false` value will be used.
+
+
+
+## HTML
+
+### Parser
+
+`MarkwonHtmlParser` is used to parse HTML content
+
+```java
+SpannableConfiguration.builder(context)
+ .htmlParser(MarkwonHtmlParser)
+ .build();
+```
+
+if not provided explicitly, default `MarkwonHtmlParserImpl` will be used
+**if** it can be found in classpath, otherwise default **no-op** implementation
+wiil be used. Refer to [HTML](/docs/v2/html.md#parser) document for more information about this behavior.
+
+### Renderer
+
+`MarkwonHtmlRenderer` controls how parsed HTML content will be rendered.
+
+```java
+SpannableConfiguration.builder(context)
+ .htmlRenderer(MarkwonHtmlRenderer)
+ .build();
+```
+
+If not provided explicitly, default `MarkwonHtmlRenderer` implementation will be used.
+It is documented [here](/docs/v2/html.md#renderer)
+
+### HTML allow non-closed tags
+
+`htmlAllowNonClosedTags` option is used to control whether or not to
+render non-closed HTML tags
+
+```java
+SpannableConfiguration.builder(context)
+ .htmlAllowNonClosedTags(boolean)
+ .build();
+```
+
+If not provided explicitly, default value `false` will be used (non-closed tags **won't** be rendered).
diff --git a/docs/docs/v2/factory.md b/docs/docs/v2/factory.md
new file mode 100644
index 00000000..186dcf3c
--- /dev/null
+++ b/docs/docs/v2/factory.md
@@ -0,0 +1,63 @@
+
+
+# Factory
+
+`SpannableFactory` is used to create Span implementations.
+
+```java
+SpannableConfiguration.builder(context)
+ .factory(SpannableFactory)
+ .build();
+```
+
+`Markwon` provides default `SpannableFactoryDef` implementation that is
+used by default.
+
+Spans:
+* `strongEmphasis`
+* `emphasis`
+* `blockQuote`
+* `code`
+* `orderedListItem`
+* `bulletListItem`
+* `thematicBreak`
+* `heading`
+* `strikethrough`
+* `taskListItem`
+* `tableRow`
+* `paragraph`
+* `image`
+* `link`
+* `superScript` (HTML content only)
+* `subScript` (HTML content only)
+* `underline` (HTML content only)
+
+:::tip
+`SpannableFactory` can be used to ignore some kinds of text markup. If, for example,
+you do not wish to apply _emphasis_ styling to your final result, just return `null`
+from `emphasis` factory method:
+```java
+@Nullable
+@Override
+public Object emphasis() {
+ return null;
+}
+```
+:::
+
+:::tip
+All factory methods in `SpannableFactory` return an `Object`, but you can actually
+return an **array of Objects** if you wish to apply multiple Spans to a single styling node.
+For example, let's make all _emphasis_ also red:
+
+```java
+@Nullable
+@Override
+public Object emphasis() {
+ return new Object[] {
+ super.emphasis(),
+ new ForegroundColorSpan(Color.RED)
+ };
+}
+```
+:::
\ No newline at end of file
diff --git a/docs/docs/v2/getting-started.md b/docs/docs/v2/getting-started.md
new file mode 100644
index 00000000..e24ca710
--- /dev/null
+++ b/docs/docs/v2/getting-started.md
@@ -0,0 +1,102 @@
+
+
+# Getting started
+
+:::tip Installation
+Please follow [installation](/docs/install.md) instructions
+to learn how to add `Markwon` to your project
+:::
+
+## Quick one
+
+This is the most simple way to set markdown to a `TextView` or any of its siblings:
+
+```java
+Markwon.setMarkdown(textView, "**Hello there!**");
+```
+
+The most simple way to obtain markdown to be applied _somewhere_ else:
+
+```java
+// parsed and styled markdown
+final CharSequence markdown = Markwon.markdown(context, "**Hello there!**");
+
+// use it
+Toast.makeText(context, markdown, Toast.LENGTH_LONG).show();
+```
+
+## Longer one
+
+When you need to customize markdown parsing/rendering you can use [SpannableConfiguration](/docs/configure.md):
+
+```java
+final SpannableConfiguration configuration = SpannableConfiguration.builder(context)
+ .asyncDrawableLoader(AsyncDrawableLoader.create())
+ .build();
+
+Markwon.setMarkdown(textView, configuration, "Are **you** still there?");
+
+final CharSequence markdown = Markwon.markdown(configuration, "Are **you** still there?");
+Toast.makeText(context, markdown, Toast.LENGTH_LONG).show();
+```
+
+## No magic one
+
+In order to understand how previous examples work, let's break them down:
+
+* construct a `Parser` (see: ) and parse markdown
+* construct a `SpannableConfiguration` (if it's not provided)
+* *render* parsed markdown to Spannable (via `SpannableRenderer`)
+* prepares TextView to display images, tables and links
+* sets text
+
+This flow answers the most simple usage of displaying markdown: one shot parsing
+& configuration of relatively small markdown chunks. If your markdown contains
+a lot of text or you plan to display multiple UI widgets with markdown you might
+consider *stepping in* and taking control of this flow.
+
+The candidate requirements to *step in*:
+* parsing and processing of parsed markdown in a background thread
+* reusing `Parser` and/or `SpannableConfiguration` between multiple calls
+* ignore images or tables specific logic (you know that markdown won't contain them)
+
+So, if we expand `Markwon.setMarkdown(textView, markdown)` method we will see the following:
+
+```java
+// create a Parser instance (can be done manually)
+// internally creates default Parser instance & registers `strike-through` & `tables` extension
+final Parser parser = Markwon.createParser();
+
+// core class to display markdown, can be obtained via this method,
+// which creates default instance (no images handling though),
+// or via `builder` method, which lets you to configure this instance
+final SpannableConfiguration configuration = SpannableConfiguration.create(context);
+
+final SpannableRenderer renderer = new SpannableRenderer();
+
+final Node node = parser.parse(markdown);
+final CharSequence text = renderer.render(configuration, node);
+
+// for links in markdown to be clickable
+textView.setMovementMethod(LinkMovementMethod.getInstance());
+
+// we need these due to the limited nature of Spannables to invalidate TextView
+Markwon.unscheduleDrawables(textView);
+Markwon.unscheduleTableRows(textView);
+
+// @since 2.0.1 we must measure ordered list items _before_ they are rendered
+OrderedListItemSpan.measure(view, text);
+
+textView.setText(text);
+
+Markwon.scheduleDrawables(textView);
+Markwon.scheduleTableRows(textView);
+```
+
+:::tip Note
+If you are having trouble with `LinkMovementMethod` you can use
+`Markwon.setText(textView, markdown, movementMethod)` method to specify _no_ movement
+method (aka `null`) or own implementation. As an alternative to the system `LinkMovementMethod`
+you can use [Better-Link-Movement-Method](https://github.com/saket/Better-Link-Movement-Method).
+Please note that `Markwon.setText` method expects _parsed_ markdown as the second argument.
+:::
\ No newline at end of file
diff --git a/docs/docs/v2/html.md b/docs/docs/v2/html.md
new file mode 100644
index 00000000..bb5e8e59
--- /dev/null
+++ b/docs/docs/v2/html.md
@@ -0,0 +1,305 @@
+
+
+# HTML
+
+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
+ and
+elements. This leads to situations when for example an `` tag is considered
+a block when it's used like this:
+
+```markdown
+
+Hello from italics tag
+
+```
+
+:::tip A bit of background
+
+ had brought attention to differences between HTML & commonmark implementations.
+:::
+
+Let's modify code snippet above _a bit_:
+
+```markdown{3}
+
+Hello from italics tag
+
+
+```
+
+We have just added a `new-line` before closing `` tag. And this
+changes everything as now, according to the ,
+we have 2 HtmlBlocks: one before `new-line` (containing open `` tag and text content)
+and one after (containing as little as closing `` tag).
+
+If we modify code snippet _a bit_ again:
+
+```markdown{4}
+
+Hello from italics tag
+
+bold>
+```
+
+We will have 1 HtmlBlock (from previous snippet) and a bunch of HtmlInlines:
+* HtmlInline (``)
+* HtmlInline (``)
+* Text (`bold`)
+* HtmlInline (``)
+
+Those _little_ differences render `Html.fromHtml` (which was used in `1.x.x` versions)
+useless. And actually it renders most of the HTML parsers implementations useless,
+as most of them do not allow processing of HTML fragments in a raw fashion
+without _fixing_ content on-the-fly.
+
+Both `TagSoup` and `Jsoup` HTML parsers (that were considered for this project) are built to deal with
+_malicious_ HTML code (*all HTML code*? :no_mouth:). So, when supplied
+with a `italic` fragment they will make it `italic`.
+And it's a good thing, but consider these fragments for the sake of markdown:
+
+* `italic `
+* `bold italic`
+* ``
+
+We will get:
+
+* `italic `
+* `bold italic`
+
+_* Or to be precise: `italic ` &
+`bold italic`_
+
+Which will be rendered in a final document:
+
+
+|expected|actual|
+|---|---|
+|italic bold italic|italic bold italic|
+
+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:!
+
+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.
+
+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 )
+
+## 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)
+ .htmlAllowNonClosedTags(true)
+ .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 (`.htmlAllowNonClosedTags(true)`),
+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
+
+Unlike `MarkwonHtmlParser` `Markwon` comes with a `MarkwonHtmlRenderer` by default.
+
+Default implementation can be obtain like this:
+
+```java
+MarkwonHtmlRenderer.create();
+```
+
+Default instance have these tags _handled_:
+* emphasis
+ * `i`
+ * `em`
+ * `cite`
+ * `dfn`
+* strong emphasis
+ * `b`
+ * `strong`
+* `sup` (super script)
+* `sub` (sub script)
+* underline
+ * `u`
+ * `ins`
+* strike through
+ * `del`
+ * `s`
+ * `strike`
+* `a` (link)
+* `ul` (unordered list)
+* `ol` (ordered list)
+* `img` (image)
+* `blockquote` (block quote)
+* `h{1-6}` (heading)
+
+If you wish to _extend_ default handling (or override existing),
+`#builderWithDefaults` factory method can be used:
+
+```java
+MarkwonHtmlRenderer.builderWithDefaults();
+```
+
+For a completely _clean_ configurable instance `#builder` method can be used:
+
+```java
+MarkwonHtmlRenderer.builder();
+```
+
+### Custom tag handler
+
+To configure `MarkwonHtmlRenderer` to handle tags differently or
+create a new tag handler - `TagHandler` can be used
+
+```java
+public abstract class TagHandler {
+
+ public abstract void handle(
+ @NonNull SpannableConfiguration configuration,
+ @NonNull SpannableBuilder builder,
+ @NonNull HtmlTag tag
+ );
+}
+```
+
+For the most simple _inline_ tag handler a `SimpleTagHandler` can be used:
+
+```java
+public abstract class SimpleTagHandler extends TagHandler {
+
+ @Nullable
+ public abstract Object getSpans(@NonNull SpannableConfiguration configuration, @NonNull HtmlTag tag);
+}
+```
+
+For example, `EmphasisHandler`:
+
+```java
+public class EmphasisHandler extends SimpleTagHandler {
+ @Nullable
+ @Override
+ public Object getSpans(@NonNull SpannableConfiguration configuration, @NonNull HtmlTag tag) {
+ return configuration.factory().emphasis();
+ }
+}
+```
+
+If you wish to handle a _block_ HTML node (for example `
First
Second
`) refer
+to `ListHandler` source code for reference.
+
+:::warning
+The most important thing when implementing custom `TagHandler` is to know
+what type of `HtmlTag` we are dealing with. There are 2: inline & block.
+Inline tag cannot contain children. Block _can_ contain children. And they
+_most likely_ should also be visited and _handled_ by registered `TagHandler` (if any)
+accordingly. See `TagHandler#visitChildren(configuration, builder, child);`
+:::
+
+#### Css inline style parser
+
+When implementing own `TagHandler` you might want to inspect inline CSS styles
+of a HTML element. `Markwon` provides an utility parser for that purpose:
+
+```java
+final CssInlineStyleParser inlineStyleParser = CssInlineStyleParser.create();
+for (CssProperty property: inlineStyleParser.parse("width: 100%; height: 100%;")) {
+ // [0] = CssProperty({width=100%}),
+ // [1] = CssProperty({height=100%})
+}
+```
+
+## Exclude HTML parsing
+
+If you wish to exclude HTML parsing altogether, you can manually
+exclude `markwon-html-parser-impl` artifact from your projects compile classpath.
+This can be beneficial if you know that markdown input won't contain
+HTML and/or you wish to ignore it. Excluding HTML parsing
+can speed up `Markwon` parsing and will decrease final size of
+`Markwon` dependency by around `100kb`.
+
+
+
+```groovy
+dependencies {
+ implementation("ru.noties:markwon:${markwonVersion}") {
+ exclude module: 'markwon-html-parser-impl'
+ }
+}
+```
+
+Excluding `markwon-html-parser-impl` this way will result in
+`MarkwonHtmlParser#noOp` implementation. No further steps are
+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 content (just a tag definition).
+:::
\ No newline at end of file
diff --git a/docs/docs/image-loader.md b/docs/docs/v2/image-loader.md
similarity index 97%
rename from docs/docs/image-loader.md
rename to docs/docs/v2/image-loader.md
index f9642215..75275961 100644
--- a/docs/docs/image-loader.md
+++ b/docs/docs/v2/image-loader.md
@@ -1,3 +1,5 @@
+
+
# Images
By default `Markwon` doesn't handle images. Although `AsyncDrawable.Loader` is
@@ -16,12 +18,12 @@ public interface Loader {
## AsyncDrawableLoader
-
+
`AsyncDrawableLoader` from `markwon-image-loader` artifact can be used.
:::tip Install
-[Learn how to add](/docs/install.md#image-loader) `markwon-image-loader` to your project
+[Learn how to add](/docs/v2/install.md#image-loader) `markwon-image-loader` to your project
:::
Default instance of `AsyncDrawableLoader` can be obtain like this:
diff --git a/docs/docs/v2/install.md b/docs/docs/v2/install.md
new file mode 100644
index 00000000..eab25066
--- /dev/null
+++ b/docs/docs/v2/install.md
@@ -0,0 +1,79 @@
+
+
+# Installation
+
+
+
+In order to start using `Markwon` add this to your dependencies block
+in your projects `build.gradle`:
+
+```groovy
+implementation "ru.noties:markwon:${markwonVersion}"
+```
+
+This is core artifact that is sufficient to start displaying markdown in your Android applications.
+
+`Markwon` comes with more artifacts that cover additional functionality, but they are
+**not** required to be used, as most of them provide implementations for functionality
+that is _interfaced_ in the core artifact
+
+```groovy
+implementation "ru.noties:markwon-image-loader:${markwonVersion}"
+implementation "ru.noties:markwon-syntax-highlight:${markwonVersion}"
+implementation "ru.noties:markwon-view:${markwonVersion}"
+```
+
+These artifacts share the same _version_ as the core artifact
+
+### Image loader
+
+```groovy
+implementation "ru.noties:markwon-image-loader:${markwonVersion}"
+```
+
+Provides implementation of `AsyncDrawable.Loader` and comes with support for:
+* SVG
+* GIF
+* Other image formats
+
+Please refer to documentation for [image loader](/docs/v2/image-loader.md) module
+
+### Syntax highlight
+
+```groovy
+implementation "ru.noties:markwon-syntax-highlight:${markwonVersion}"
+```
+
+Provides implementation of `SyntaxHighlight` and allows various syntax highlighting
+in your markdown based Android applications. Comes with 2 ready-to-be-used themes: `light` and `dark`.
+Please refer to documentation for [syntax highlight](/docs/v2/syntax-highlight.md) module
+
+### View
+
+```groovy
+implementation "ru.noties:markwon-view:${markwonVersion}"
+```
+
+Provides 2 widgets to display markdown: `MarkwonView` and `MarkwonViewCompat` (subclasses
+of `TextView` and `AppCompatTextView` respectively).
+Please refer to documentation for [view](/docs/v2/view.md) module
+
+## Proguard
+
+When using `markwon-image-loader` artifact and Proguard is enabled, add these rules
+to your proguard configuration:
+
+```proguard
+-dontwarn okhttp3.**
+-dontwarn okio.**
+
+-keep class com.caverock.androidsvg.** { *; }
+-dontwarn com.caverock.androidsvg.**
+```
+
+They come from dependencies that `markwon-image-loader` is using.
+
+:::tip Other artifacts
+Other artifacts do not require special Proguard rules
+:::
+
diff --git a/docs/docs/syntax-highlight.md b/docs/docs/v2/syntax-highlight.md
similarity index 96%
rename from docs/docs/syntax-highlight.md
rename to docs/docs/v2/syntax-highlight.md
index 64454903..4aa1795e 100644
--- a/docs/docs/syntax-highlight.md
+++ b/docs/docs/v2/syntax-highlight.md
@@ -1,6 +1,8 @@
+
+
# Syntax highlight
-
+
This is a simple module to add **syntax highlight** functionality to your markdown rendered with `Markwon` library. It is based on [Prism4j](https://github.com/noties/Prism4j) so lead there to understand how to configure `Prism4j` instance.
diff --git a/docs/docs/theme.md b/docs/docs/v2/theme.md
similarity index 98%
rename from docs/docs/theme.md
rename to docs/docs/v2/theme.md
index 4bc6cfb0..269155fe 100644
--- a/docs/docs/theme.md
+++ b/docs/docs/v2/theme.md
@@ -1,3 +1,5 @@
+
+
# Theme
Here is the list of properties that can be configured via `SpannableTheme#builder` factory
@@ -209,4 +211,4 @@ Background of header table row
Drawable of task list item
-
+
diff --git a/docs/docs/view.md b/docs/docs/v2/view.md
similarity index 95%
rename from docs/docs/view.md
rename to docs/docs/v2/view.md
index c43b4e9d..c365fd42 100644
--- a/docs/docs/view.md
+++ b/docs/docs/v2/view.md
@@ -1,6 +1,8 @@
+
+
# MarkwonView
-
+
This is simple library containing 2 views that are able to display markdown:
* MarkwonView - extends `android.view.TextView`
@@ -27,7 +29,8 @@ public interface IMarkwonView {
Both views support layout-preview in Android Studio (with some exceptions, for example, bold span is not rendered due to some limitations of layout preview).
These are XML attributes:
-```
+
+```xml
app:mv_markdown="string"
app:mv_configurationProvider="string"
```
diff --git a/markwon-ext-latex/README.md b/markwon-ext-latex/README.md
index 5937fd6b..aa1348c3 100644
--- a/markwon-ext-latex/README.md
+++ b/markwon-ext-latex/README.md
@@ -1,6 +1,8 @@
# LaTeX
-This is a small extension that will help you display LaTeX formulas in your markdown.
+[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties.markwon%22%20AND%20a%3A%22ext-latex%22)
+
+This is an extension that will help you display LaTeX formulas in your markdown.
Syntax is pretty simple: pre-fix and post-fix your latex with `$$` (double dollar sign).
`$$` should be the first characters in a line.
@@ -16,7 +18,6 @@ $$\\text{A long division \\longdiv{12345}{13}$$
```java
Markwon.builder(context)
- .use(CorePlugin.create())
.use(ImagesPlugin.create(context))
.use(JLatexMathPlugin.create(new Config(textSize))
.build();
diff --git a/markwon-ext-strikethrough/README.md b/markwon-ext-strikethrough/README.md
index 55b9e542..acd8b513 100644
--- a/markwon-ext-strikethrough/README.md
+++ b/markwon-ext-strikethrough/README.md
@@ -1,6 +1,6 @@
# Strikethrough
-[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-ext-strikethrough%22)
+[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties.markwon%22%20AND%20a%3A%22ext-strikethrough%22)
This module adds `strikethrough` functionality to `Markwon` via `StrikethroughPlugin`:
@@ -13,7 +13,7 @@ This plugin registers `SpanFactory` for `Strikethrough` node, so it's possible t
```java
Markwon.builder(context)
- .usePlugin(StrikethroughPlugin.class)
+ .usePlugin(StrikethroughPlugin.create())
.usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureSpansFactory(@NonNull MarkwonSpansFactory.Builder builder) {
diff --git a/markwon-ext-tables/README.md b/markwon-ext-tables/README.md
new file mode 100644
index 00000000..6f94bd2d
--- /dev/null
+++ b/markwon-ext-tables/README.md
@@ -0,0 +1,45 @@
+# Tables
+
+[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties.markwon%22%20AND%20a%3A%22ext-tables%22)
+
+This extension adds support for GFM tables.
+
+```java
+final Markwon markwon = Markwon.builder(context)
+ // create default instance of TablePlugin
+ .usePlugin(TablePlugin.create(context))
+```
+
+```java
+final TableTheme tableTheme = TableTheme.builder()
+ .tableBorderColor(Color.RED)
+ .tableBorderWidth(0)
+ .tableCellPadding(0)
+ .tableHeaderRowBackgroundColor(Color.BLACK)
+ .tableEvenRowBackgroundColor(Color.GREEN)
+ .tableOddRowBackgroundColor(Color.YELLOW)
+ .build();
+
+final Markwon markwon = Markwon.builder(context)
+ .usePlugin(TablePlugin.create(tableTheme))
+```
+
+Please note, that _by default_ tables have limitations. For example, there is no support
+for images inside table cells. And table contents won't be copied to clipboard if a TextView
+has such functionality. Table will always take full width of a TextView in which it is displayed.
+All columns will always be the of the same width. So, _default_ implementation provides basic
+functionality which can answer some needs. These all come from the limited nature of the TextView
+to display such content.
+
+In order to provide full-fledged experience, tables must be displayed in a special widget.
+Since version `3.0.0` Markwon provides a special artifact `markwon-recycler` that allows
+to render markdown in a set of widgets in a RecyclerView. It also gives ability to change
+display widget form TextView to any other.
+
+```java
+final Table table = Table.parse(Markwon, TableBlock);
+myTableWidget.setTable(table);
+```
+
+Unfortunately Markwon does not provide a widget that can be used for tables. But it does
+provide API that can be used to achieve desired result.
diff --git a/markwon-ext-tables/src/main/java/ru/noties/markwon/ext/tables/TablePlugin.java b/markwon-ext-tables/src/main/java/ru/noties/markwon/ext/tables/TablePlugin.java
index ae547435..d6a5d26e 100644
--- a/markwon-ext-tables/src/main/java/ru/noties/markwon/ext/tables/TablePlugin.java
+++ b/markwon-ext-tables/src/main/java/ru/noties/markwon/ext/tables/TablePlugin.java
@@ -52,6 +52,7 @@ public class TablePlugin extends AbstractMarkwonPlugin {
@Override
public void beforeRender(@NonNull Node node) {
+ // clear before rendering (as visitor has some internal mutable state)
visitor.clear();
}
diff --git a/markwon-view/README.md b/markwon-view/README.md
deleted file mode 100644
index 71f032db..00000000
--- a/markwon-view/README.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Markwon View
-
-[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%markwon-view%22)
-
-This is simple library containing 2 views that are able to display markdown:
-* MarkwonView - extends `android.view.TextView`
-* MarkwonViewCompat - extends `android.support.v7.widget.AppCompatTextView`
-
-Both of them implement common `IMarkwonView` interface:
-```java
-public interface IMarkwonView {
-
- interface ConfigurationProvider {
- @NonNull
- SpannableConfiguration provide(@NonNull Context context);
- }
-
- void setConfigurationProvider(@NonNull ConfigurationProvider provider);
-
- void setMarkdown(@Nullable String markdown);
- void setMarkdown(@Nullable SpannableConfiguration configuration, @Nullable String markdown);
-
- @Nullable
- String getMarkdown();
-}
-```
-
-Both views support layout-preview in Android Studio (with some exceptions, for example, bold span is not rendered due to some limitations of layout preview).
-These are XML attributes:
-```
-app:mv_markdown="string"
-app:mv_configurationProvider="string"
-```
-
-`mv_markdown` accepts a string and represents raw markdown
-
-`mv_configurationProvider` accepts a string and represents a full class name of a class of type `ConfigurationProvider`,
-for example: `com.example.my.package.MyConfigurationProvider` (this class must have an empty constructor
-in order to be instantiated via reflection).
-
-Please note that those views parse markdown in main thread, so their usage must be for relatively small markdown portions only
diff --git a/markwon-view/build.gradle b/markwon-view/build.gradle
deleted file mode 100644
index 5e4e72ab..00000000
--- a/markwon-view/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
-
- compileSdkVersion config['compile-sdk']
- buildToolsVersion config['build-tools']
-
- defaultConfig {
- minSdkVersion config['min-sdk']
- targetSdkVersion config['target-sdk']
- versionCode 1
- versionName version
- }
-}
-
-dependencies {
-
- api project(':markwon')
-
- deps.with {
- compileOnly it['support-app-compat']
- }
-}
-
-registerArtifact(this)
diff --git a/markwon-view/src/debug/java/ru/noties/markwon/view/debug/DebugConfigurationProvider.java b/markwon-view/src/debug/java/ru/noties/markwon/view/debug/DebugConfigurationProvider.java
deleted file mode 100644
index f88ba5ae..00000000
--- a/markwon-view/src/debug/java/ru/noties/markwon/view/debug/DebugConfigurationProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package ru.noties.markwon.view.debug;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-
-import ru.noties.markwon.MarkwonConfiguration;
-import ru.noties.markwon.core.MarkwonTheme;
-import ru.noties.markwon.view.IMarkwonView;
-
-public class DebugConfigurationProvider implements IMarkwonView.ConfigurationProvider {
-
- private MarkwonConfiguration cached;
-
- @NonNull
- @Override
- public MarkwonConfiguration provide(@NonNull Context context) {
- if (cached == null) {
- cached = MarkwonConfiguration.builder(context)
- .theme(debugTheme(context))
- .build();
- }
- return cached;
- }
-
- private static MarkwonTheme debugTheme(@NonNull Context context) {
- return MarkwonTheme.builderWithDefaults(context)
- .blockQuoteColor(0xFFff0000)
- .codeBackgroundColor(0x40FF0000)
- .build();
- }
-}
diff --git a/markwon-view/src/debug/res/layout/debug_markwon_preview.xml b/markwon-view/src/debug/res/layout/debug_markwon_preview.xml
deleted file mode 100644
index ecc7bd3d..00000000
--- a/markwon-view/src/debug/res/layout/debug_markwon_preview.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/markwon-view/src/debug/res/layout/debug_markwon_preview_compat.xml b/markwon-view/src/debug/res/layout/debug_markwon_preview_compat.xml
deleted file mode 100644
index 092dbf00..00000000
--- a/markwon-view/src/debug/res/layout/debug_markwon_preview_compat.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/markwon-view/src/debug/res/values/debug_strings.xml b/markwon-view/src/debug/res/values/debug_strings.xml
deleted file mode 100644
index e7b87ab2..00000000
--- a/markwon-view/src/debug/res/values/debug_strings.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
- Quote
- \n
- >> Quote #2
- \n
- >>> Quote `#3`
- \n
- ---
- \n
- ```
- \n
- // this is some amazing code block
- \n
- ```
- \n
- * First
- \n
- * Second
- \n
- * * Second-First
- \n
- * * Second-Second
- \n
- * * * Second-Second-First
- \n
- * And out of blue - Third
- ]]>
-
-
-
\ No newline at end of file
diff --git a/markwon-view/src/main/AndroidManifest.xml b/markwon-view/src/main/AndroidManifest.xml
deleted file mode 100644
index 6340e29d..00000000
--- a/markwon-view/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/markwon-view/src/main/java/ru/noties/markwon/view/IMarkwonView.java b/markwon-view/src/main/java/ru/noties/markwon/view/IMarkwonView.java
deleted file mode 100644
index bc66e8b8..00000000
--- a/markwon-view/src/main/java/ru/noties/markwon/view/IMarkwonView.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package ru.noties.markwon.view;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import ru.noties.markwon.MarkwonConfiguration;
-
-public interface IMarkwonView {
-
- interface ConfigurationProvider {
- @NonNull
- MarkwonConfiguration provide(@NonNull Context context);
- }
-
- void setConfigurationProvider(@NonNull ConfigurationProvider provider);
-
- void setMarkdown(@Nullable String markdown);
- void setMarkdown(@Nullable MarkwonConfiguration configuration, @Nullable String markdown);
-
- @Nullable
- String getMarkdown();
-}
diff --git a/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonView.java b/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonView.java
deleted file mode 100644
index f42d8727..00000000
--- a/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonView.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package ru.noties.markwon.view;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import ru.noties.markwon.MarkwonConfiguration;
-
-@SuppressLint("AppCompatCustomView")
-public class MarkwonView extends TextView implements IMarkwonView {
-
- private MarkwonViewHelper helper;
-
- public MarkwonView(Context context) {
- super(context);
- init(context, null);
- }
-
- public MarkwonView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs);
- }
-
- private void init(Context context, AttributeSet attributeSet) {
- helper = MarkwonViewHelper.create(this);
- helper.init(context, attributeSet);
- }
-
- @Override
- public void setConfigurationProvider(@NonNull ConfigurationProvider provider) {
- helper.setConfigurationProvider(provider);
- }
-
- public void setMarkdown(@Nullable String markdown) {
- helper.setMarkdown(markdown);
- }
-
- public void setMarkdown(@Nullable MarkwonConfiguration configuration, @Nullable String markdown) {
- helper.setMarkdown(configuration, markdown);
- }
-
- @Nullable
- @Override
- public String getMarkdown() {
- return helper.getMarkdown();
- }
-}
diff --git a/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonViewCompat.java b/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonViewCompat.java
deleted file mode 100644
index b30ecaa2..00000000
--- a/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonViewCompat.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package ru.noties.markwon.view;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.AppCompatTextView;
-import android.util.AttributeSet;
-
-import ru.noties.markwon.MarkwonConfiguration;
-
-public class MarkwonViewCompat extends AppCompatTextView implements IMarkwonView {
-
- private MarkwonViewHelper helper;
-
- public MarkwonViewCompat(Context context) {
- super(context);
- init(context, null);
- }
-
- public MarkwonViewCompat(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs);
- }
-
- private void init(Context context, AttributeSet attributeSet) {
- helper = MarkwonViewHelper.create(this);
- helper.init(context, attributeSet);
- }
-
- @Override
- public void setConfigurationProvider(@NonNull ConfigurationProvider provider) {
- helper.setConfigurationProvider(provider);
- }
-
- @Override
- public void setMarkdown(@Nullable String markdown) {
- helper.setMarkdown(markdown);
- }
-
- @Override
- public void setMarkdown(@Nullable MarkwonConfiguration configuration, @Nullable String markdown) {
- helper.setMarkdown(configuration, markdown);
- }
-
- @Nullable
- @Override
- public String getMarkdown() {
- return helper.getMarkdown();
- }
-}
diff --git a/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonViewHelper.java b/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonViewHelper.java
deleted file mode 100644
index f3669b77..00000000
--- a/markwon-view/src/main/java/ru/noties/markwon/view/MarkwonViewHelper.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package ru.noties.markwon.view;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import ru.noties.markwon.Markwon;
-import ru.noties.markwon.MarkwonConfiguration;
-
-public class MarkwonViewHelper implements IMarkwonView {
-
- public static MarkwonViewHelper create(@NonNull V view) {
- return new MarkwonViewHelper(view);
- }
-
- private final TextView textView;
-
- private ConfigurationProvider provider;
-
- private MarkwonConfiguration configuration;
- private String markdown;
-
- private MarkwonViewHelper(@NonNull TextView textView) {
- this.textView = textView;
- }
-
- public void init(Context context, AttributeSet attributeSet) {
-
- if (attributeSet != null) {
- final TypedArray array = context.obtainStyledAttributes(attributeSet, R.styleable.MarkwonView);
- try {
-
- final String configurationProvider = array.getString(R.styleable.MarkwonView_mv_configurationProvider);
- final ConfigurationProvider provider;
- if (!TextUtils.isEmpty(configurationProvider)) {
- provider = MarkwonViewHelper.obtainProvider(configurationProvider);
- } else {
- provider = null;
- }
- if (provider != null) {
- setConfigurationProvider(provider);
- }
-
- final String markdown = array.getString(R.styleable.MarkwonView_mv_markdown);
- if (!TextUtils.isEmpty(markdown)) {
- setMarkdown(markdown);
- }
- } finally {
- array.recycle();
- }
- }
- }
-
- @Override
- public void setConfigurationProvider(@NonNull ConfigurationProvider provider) {
- this.provider = provider;
- this.configuration = provider.provide(textView.getContext());
- if (!TextUtils.isEmpty(markdown)) {
- // invalidate rendered markdown
- setMarkdown(markdown);
- }
- }
-
- @Override
- public void setMarkdown(@Nullable String markdown) {
- setMarkdown(null, markdown);
- }
-
- @Override
- public void setMarkdown(@Nullable MarkwonConfiguration configuration, @Nullable String markdown) {
- this.markdown = markdown;
- if (configuration == null) {
- if (this.configuration == null) {
- if (provider != null) {
- this.configuration = provider.provide(textView.getContext());
- } else {
- this.configuration = MarkwonConfiguration.create(textView.getContext());
- }
- }
- configuration = this.configuration;
- }
- Markwon.setMarkdown(textView, configuration, markdown);
- }
-
- @Nullable
- @Override
- public String getMarkdown() {
- return markdown;
- }
-
- @Nullable
- public static IMarkwonView.ConfigurationProvider obtainProvider(@NonNull String className) {
- try {
- final Class> cl = Class.forName(className);
- return (IMarkwonView.ConfigurationProvider) cl.newInstance();
- } catch (Throwable t) {
- t.printStackTrace();
- return null;
- }
- }
-}
diff --git a/markwon-view/src/main/res/values/attrs.xml b/markwon-view/src/main/res/values/attrs.xml
deleted file mode 100644
index 33a532f3..00000000
--- a/markwon-view/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/README.md b/sample-custom-extension/README.md
deleted file mode 100644
index 194557ab..00000000
--- a/sample-custom-extension/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Custom extension
-
-This module provides a simple implementation for icons that are bundled in your application resources using custom `DelimiterProcessor`. It can be used as a reference when dealing with new functionality based on _delimiters_.
-
-```markdown
-# Hello @ic-android-black-24
-
-**Please** click @ic-home-green-24 (home icon) if you want to go home.
-```
-
-Here we will substitute elements starting with `@ic-` for icons that we have in our resources:
-
-* `@ic-android-black-24` -> `R.drawable.ic_android_black_24dp`
-* `@ic-home-green-24` -> `R.drawable.ic_home_green_24dp`
-
-In order to provide reliable parsing we need to have delimiters _around_ desired content. So, `@ic-home-green-24` would become `@ic-home-green-24@`. This is current limitation of [commonmark-java](https://github.com/atlassian/commonmark-java) library that Markwon uses underneath. There is an ongoing [issue](https://github.com/atlassian/commonmark-java/issues/113) that might change this in future thought.
-
-But as we known the pattern beforehand it's pretty easy to pre-process raw markdown and make it the way we want it. Please refer to `IconProcessor#process` method for the reference.
-
-So, the our steps would be:
-
-* prepare raw markdown (wrap icons with `@` if it's not already)
-* construct a Parser with our registered delimiter processor
-* parse markdown and obtain a `Node`
-* create a node visitor that will additionally visit custom node (`IconNode`)
-* use markdown
diff --git a/sample-custom-extension/build.gradle b/sample-custom-extension/build.gradle
deleted file mode 100644
index e78a0cf5..00000000
--- a/sample-custom-extension/build.gradle
+++ /dev/null
@@ -1,29 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
-
- compileSdkVersion config['compile-sdk']
- buildToolsVersion config['build-tools']
-
- defaultConfig {
-
- applicationId "ru.noties.markwon.sample.extension"
-
- // using 21 as minimum only to be able to vector assets
- minSdkVersion 21
- targetSdkVersion config['target-sdk']
- versionCode 1
- versionName version
- }
-}
-
-dependencies {
- implementation project(':markwon-core')
-
- implementation project(':markwon-image-svg')
- implementation project(':markwon-recycler')
- implementation project(':markwon-ext-tables')
- implementation project(':markwon-html')
-
- implementation deps['debug']
-}
diff --git a/sample-custom-extension/src/main/AndroidManifest.xml b/sample-custom-extension/src/main/AndroidManifest.xml
deleted file mode 100644
index bc18eebe..00000000
--- a/sample-custom-extension/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/assets/README.md b/sample-custom-extension/src/main/assets/README.md
deleted file mode 100644
index be6976a9..00000000
--- a/sample-custom-extension/src/main/assets/README.md
+++ /dev/null
@@ -1,313 +0,0 @@
-
-
-# Markwon
-
-[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon%22)
-[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-image-loader%22)
-[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-syntax-highlight%22)
-[](http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22markwon-view%22)
-
-[](https://travis-ci.org/noties/Markwon)
-
-**Markwon** is a markdown library for Android. It parses markdown
-following [commonmark-spec] with the help of amazing [commonmark-java]
-library and renders result as _Android-native_ Spannables. **No HTML**
-is involved as an intermediate step. **No WebView** is required.
-It's extremely fast, feature-rich and extensible.
-
-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**, **markdown tables**,
-**images** and **syntax highlight**).
-
-[commonmark-spec]: https://spec.commonmark.org/0.28/
-[commonmark-java]: https://github.com/atlassian/commonmark-java/blob/master/README.md
-
-**This file is displayed by default in the [sample-apk] (`markwon-sample-{latest-version}-debug.apk`) application. Which is a generic markdown viewer with support to display markdown via `http`, `https` & `file` schemes and 2 themes included: Light & Dark*
-
-[sample-apk]: https://github.com/noties/Markwon/releases
-
-## Installation
-```groovy
-implementation "ru.noties:markwon:${markwonVersion}"
-implementation "ru.noties:markwon-image-loader:${markwonVersion}" // optional
-implementation "ru.noties:markwon-syntax-highlight:${markwonVersion}" // optional
-implementation "ru.noties:markwon-view:${markwonVersion}" // optional
-```
-
-Please visit [documentation] web-site for further reference
-
-## Supported markdown features:
-* Emphasis (`*`, `_`)
-* Strong emphasis (`**`, `__`)
-* Strike-through (`~~`)
-* Headers (`#{1,6}`)
-* Links (`[]()` && `[][]`)
-* Images
-* Thematic break (`---`, `***`, `___`)
-* Quotes & nested quotes (`>{1,}`)
-* Ordered & non-ordered lists & nested ones
-* Inline code
-* Code blocks
-* Tables (*with limitations*)
-* Syntax highlight
-* HTML
- * Emphasis (``, ``, ``, ``)
- * Strong emphasis (``, ``)
- * SuperScript (``)
- * SubScript (``)
- * Underline (``, `ins`)
- * Strike-through (``, ``, ``)
- * Link (`a`)
- * Lists (`ul`, `ol`)
- * Images (`img` will require configured image loader)
- * Blockquote (`blockquote`)
- * Heading (`h1`, `h2`, `h3`, `h4`, `h5`, `h6`)
- * there is support to render any HTML tag
-* Task lists:
-- [ ] Not _done_
- - [X] **Done** with `X`
- - [x] ~~and~~ **or** small `x`
----
-
-## Screenshots
-
-Taken with default configuration (except for image loading):
-
-
-
-
-
-
-By default configuration uses TextView textColor for styling, so changing textColor changes style
-
----
-
-## Documentation
-
-Please visit [documentation] web-site for reference
-
-[documentation]: https://noties.github.io/Markwon
-
----
-
-## Applications using Markwon
-
-* [Partiko](https://partiko.app)
-* [FairNote Notepad](https://play.google.com/store/apps/details?id=com.rgiskard.fairnote)
-
-
----
-
-# Demo
-Based on [this cheatsheet][cheatsheet]
-
----
-
-## Headers
----
-# Header 1
-## Header 2
-### Header 3
-#### Header 4
-##### Header 5
-###### Header 6
----
-
-## Emphasis
-
-Emphasis, aka italics, with *asterisks* or _underscores_.
-
-Strong emphasis, aka bold, with **asterisks** or __underscores__.
-
-Combined emphasis with **asterisks and _underscores_**.
-
-Strikethrough uses two tildes. ~~Scratch this.~~
-
----
-
-## Lists
-1. First ordered list item
-2. Another item
- * Unordered sub-list.
-1. Actual numbers don't matter, just that it's a number
- 1. Ordered sub-list
-4. And another item.
-
- You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
-
- To have a line break without a paragraph, you will need to use two trailing spaces.
- Note that this line is separate, but within the same paragraph.
- (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
-
-* Unordered list can use asterisks
-- Or minuses
-+ Or pluses
-
----
-
-## Links
-
-[I'm an inline-style link](https://www.google.com)
-
-[I'm a reference-style link][Arbitrary case-insensitive reference text]
-
-[I'm a relative reference to a repository file](../blob/master/LICENSE)
-
-[You can use numbers for reference-style link definitions][1]
-
-Or leave it empty and use the [link text itself].
-
----
-
-## Code
-
-Inline `code` has `back-ticks around` it.
-
-```javascript
-var s = "JavaScript syntax highlighting";
-alert(s);
-```
-
-```python
-s = "Python syntax highlighting"
-print s
-```
-
-```java
-/**
- * Helper method to obtain a Parser with registered strike-through & table extensions
- * & task lists (added in 1.0.1)
- *
- * @return a Parser instance that is supported by this library
- * @since 1.0.0
- */
-@NonNull
-public static Parser createParser() {
- return new Parser.Builder()
- .extensions(Arrays.asList(
- StrikethroughExtension.create(),
- TablesExtension.create(),
- TaskListExtension.create()
- ))
- .build();
-}
-```
-
-```xml
-
-
-
-
-
-```
-
-```
-No language indicated, so no syntax highlighting.
-But let's throw in a tag.
-```
-
----
-
-## Tables
-
-Colons can be used to align columns.
-
-| Tables | Are | Cool |
-| ------------- |:-------------:| -----:|
-| col 3 is | right-aligned | $1600 |
-| col 2 is | centered | $12 |
-| zebra stripes | are neat | $1 |
-
-There must be at least 3 dashes separating each header cell.
-The outer pipes (|) are optional, and you don't need to make the
-raw Markdown line up prettily. You can also use inline Markdown.
-
-Markdown | Less | Pretty
---- | --- | ---
-*Still* | `renders` | **nicely**
-1 | 2 | 3
-
----
-
-## Blockquotes
-
-> Blockquotes are very handy in email to emulate reply text.
-> This line is part of the same quote.
-
-Quote break.
-
-> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
-
-Nested quotes
-> Hello!
->> And to you!
-
----
-
-## Inline HTML
-
-```html
-HTML
-```
-
-HTML
-
----
-
-## Horizontal Rule
-
-Three or more...
-
----
-
-Hyphens (`-`)
-
-***
-
-Asterisks (`*`)
-
-___
-
-Underscores (`_`)
-
-
-## License
-
-```
- Copyright 2017 Dimitry Ivanov (mail@dimitryivanov.ru)
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-```
-
-[cheatsheet]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
-
-[arbitrary case-insensitive reference text]: https://www.mozilla.org
-[1]: http://slashdot.org
-[link text itself]: http://www.reddit.com
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/MainActivity.java b/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/MainActivity.java
deleted file mode 100644
index 4975dc38..00000000
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/MainActivity.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package ru.noties.markwon.sample.extension;
-
-import android.app.Activity;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.widget.TextView;
-
-import ru.noties.markwon.AbstractMarkwonPlugin;
-import ru.noties.markwon.Markwon;
-import ru.noties.markwon.core.MarkwonTheme;
-
-public class MainActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.activity_main);
-
- final TextView textView = findViewById(R.id.text_view);
-
- final Markwon markwon = Markwon.builder(this)
- .usePlugin(IconPlugin.create(IconSpanProvider.create(this, 0)))
- .usePlugin(new AbstractMarkwonPlugin() {
- @Override
- public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
- // this part has nothing to do with actual IconPlugin
- // this part is used to showcase that headers can be controlled via Theme
- final float[] textSizeMultipliers = new float[]{3f, 2f, 1.5f, 1f, .5f, .25f};
- builder
- .headingTypeface(Typeface.MONOSPACE)
- .headingTextSizeMultipliers(textSizeMultipliers);
- }
- })
- .build();
-
- markwon.setMarkdown(textView, getString(R.string.input));
- }
-}
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/MarkwonRecyclerActivity.java b/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/MarkwonRecyclerActivity.java
deleted file mode 100644
index eb4dc039..00000000
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/MarkwonRecyclerActivity.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package ru.noties.markwon.sample.extension.recycler;
-
-import android.app.Activity;
-import android.content.Context;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-
-import org.commonmark.ext.gfm.tables.TableBlock;
-import org.commonmark.node.FencedCodeBlock;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import ru.noties.debug.AndroidLogDebugOutput;
-import ru.noties.debug.Debug;
-import ru.noties.markwon.AbstractMarkwonPlugin;
-import ru.noties.markwon.Markwon;
-import ru.noties.markwon.MarkwonConfiguration;
-import ru.noties.markwon.core.CorePlugin;
-import ru.noties.markwon.ext.tables.TablePlugin;
-import ru.noties.markwon.html.HtmlPlugin;
-import ru.noties.markwon.image.ImagesPlugin;
-import ru.noties.markwon.image.svg.SvgPlugin;
-import ru.noties.markwon.recycler.MarkwonAdapter;
-import ru.noties.markwon.recycler.SimpleEntry;
-import ru.noties.markwon.sample.extension.R;
-import ru.noties.markwon.urlprocessor.UrlProcessor;
-import ru.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
-
-// we will create a standalone `sample` module with all these samples, right now this
-// module has unrelated things
-public class MarkwonRecyclerActivity extends Activity {
-
- static {
- Debug.init(new AndroidLogDebugOutput(true));
- }
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_recycler);
-
- final MarkwonAdapter adapter = MarkwonAdapter.builder()
- .include(FencedCodeBlock.class, new SimpleEntry(R.layout.adapter_fenced_code_block))
- .include(TableBlock.class, new TableEntry())
- .defaultEntry(new SimpleEntry(R.layout.adapter_default_entry))
- .build();
-
- final RecyclerView recyclerView = findViewById(R.id.recycler_view);
- recyclerView.setLayoutManager(new LinearLayoutManager(this));
- recyclerView.setHasFixedSize(true);
- recyclerView.setAdapter(adapter);
-
- final Markwon markwon = markwon(this);
- adapter.setMarkdown(markwon, loadReadMe(this));
- adapter.notifyDataSetChanged();
- }
-
- @NonNull
- private static Markwon markwon(@NonNull Context context) {
- return Markwon.builder(context)
- .usePlugin(CorePlugin.create())
- .usePlugin(ImagesPlugin.createWithAssets(context))
- .usePlugin(SvgPlugin.create(context.getResources()))
- .usePlugin(TablePlugin.create(context))
- .usePlugin(HtmlPlugin.create())
- .usePlugin(new AbstractMarkwonPlugin() {
- @Override
- public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
- builder.urlProcessor(new UrlProcessorInitialReadme());
- }
- })
- .build();
- }
-
- private static String loadReadMe(@NonNull Context context) {
- InputStream stream = null;
- try {
- stream = context.getAssets().open("README.md");
- } catch (IOException e) {
- e.printStackTrace();
- }
- return readStream(stream);
- }
-
- private static String readStream(@Nullable InputStream inputStream) {
-
- String out = null;
-
- if (inputStream != null) {
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new InputStreamReader(inputStream));
- final StringBuilder builder = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- builder.append(line)
- .append('\n');
- }
- out = builder.toString();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // no op
- }
- }
- }
- }
-
- return out;
- }
-
- private static class UrlProcessorInitialReadme implements UrlProcessor {
-
- private static final String GITHUB_BASE = "https://github.com/noties/Markwon/raw/master/";
-
- private final UrlProcessorRelativeToAbsolute processor
- = new UrlProcessorRelativeToAbsolute(GITHUB_BASE);
-
- @NonNull
- @Override
- public String process(@NonNull String destination) {
- String out;
- final Uri uri = Uri.parse(destination);
- if (TextUtils.isEmpty(uri.getScheme())) {
- out = processor.process(destination);
- } else {
- out = destination;
- }
- return out;
- }
- }
-}
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/TableEntry.java b/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/TableEntry.java
deleted file mode 100644
index aa3d79ff..00000000
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/TableEntry.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package ru.noties.markwon.sample.extension.recycler;
-
-import android.support.annotation.NonNull;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.commonmark.ext.gfm.tables.TableBlock;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import ru.noties.markwon.Markwon;
-import ru.noties.markwon.ext.tables.Table;
-import ru.noties.markwon.recycler.MarkwonAdapter;
-import ru.noties.markwon.sample.extension.R;
-
-// do not use in real applications, this is just a showcase
-public class TableEntry implements MarkwonAdapter.Entry {
-
- private final Map cache = new HashMap<>(2);
-
- @NonNull
- @Override
- public TableNodeHolder createHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
- return new TableNodeHolder(inflater.inflate(R.layout.adapter_table_block, parent, false));
- }
-
- @Override
- public void bindHolder(@NonNull Markwon markwon, @NonNull TableNodeHolder holder, @NonNull TableBlock node) {
-
- Table table = cache.get(node);
- if (table == null) {
- table = Table.parse(markwon, node);
- cache.put(node, table);
- }
-
- if (table != null) {
- holder.tableEntryView.setTable(table);
- // render table
- } // we need to do something with null table...
- }
-
- @Override
- public long id(@NonNull TableBlock node) {
- return node.hashCode();
- }
-
- @Override
- public void clear() {
- cache.clear();
- }
-
- static class TableNodeHolder extends MarkwonAdapter.Holder {
-
- final TableEntryView tableEntryView;
-
- TableNodeHolder(@NonNull View itemView) {
- super(itemView);
-
- this.tableEntryView = requireView(R.id.table_entry);
- }
- }
-}
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/TableEntryView.java b/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/TableEntryView.java
deleted file mode 100644
index 0bf133ee..00000000
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/recycler/TableEntryView.java
+++ /dev/null
@@ -1,205 +0,0 @@
-package ru.noties.markwon.sample.extension.recycler;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.SpannedString;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ru.noties.markwon.ext.tables.Table;
-import ru.noties.markwon.sample.extension.R;
-
-public class TableEntryView extends LinearLayout {
-
- // paint and rect to draw borders
- private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
- private final Rect rect = new Rect();
-
- private LayoutInflater inflater;
-
- private int rowEvenBackgroundColor;
-
- public TableEntryView(Context context) {
- super(context);
- init(context, null);
- }
-
- public TableEntryView(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs);
- }
-
- private void init(Context context, @Nullable AttributeSet attrs) {
- inflater = LayoutInflater.from(context);
- setOrientation(VERTICAL);
-
- if (attrs != null) {
- final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.TableEntryView);
- try {
-
- rowEvenBackgroundColor = array.getColor(R.styleable.TableEntryView_tev_rowEvenBackgroundColor, 0);
-
-
- final int stroke = array.getDimensionPixelSize(R.styleable.TableEntryView_tev_borderWidth, 0);
-
- // half of requested
- final float strokeWidth = stroke > 0
- ? stroke / 2.F
- : context.getResources().getDisplayMetrics().density / 2.F;
-
- paint.setStyle(Paint.Style.STROKE);
- paint.setStrokeWidth(strokeWidth);
- paint.setColor(array.getColor(R.styleable.TableEntryView_tev_borderColor, Color.BLACK));
-
- if (isInEditMode()) {
- final String data = array.getString(R.styleable.TableEntryView_tev_debugData);
- if (data != null) {
-
- boolean first = true;
-
- final List rows = new ArrayList<>();
- for (String row : data.split("\\|")) {
- final List columns = new ArrayList<>();
- for (String column : row.split(",")) {
- columns.add(new Table.Column(Table.Alignment.LEFT, new SpannedString(column)));
- }
- final boolean header = first;
- first = false;
- rows.add(new Table.Row(header, columns));
- }
- final Table table = new Table(rows);
- setTable(table);
- }
- }
- } finally {
- array.recycle();
- }
- }
-
- setWillNotDraw(false);
- }
-
- public void setTable(@NonNull Table table) {
- final List rows = table.rows();
- for (int i = 0, size = rows.size(); i < size; i++) {
- addRow(i, rows.get(i));
- }
- }
-
- private void addRow(int index, @NonNull Table.Row row) {
-
- final ViewGroup group = ensureRow(index);
-
- final int backgroundColor = !row.header() && (index % 2) == 0
- ? rowEvenBackgroundColor
- : 0;
- group.setBackgroundColor(backgroundColor);
-
- final List columns = row.columns();
-
- TextView textView;
- Table.Column column;
-
- for (int i = 0, size = columns.size(); i < size; i++) {
- textView = ensureCell(group, i);
- column = columns.get(i);
- textView.setTextAlignment(textAlignment(column.alignment()));
- textView.setText(column.content());
- textView.getPaint().setFakeBoldText(row.header());
- }
- }
-
- @NonNull
- private ViewGroup ensureRow(int index) {
-
- final int count = getChildCount();
- if (index >= count) {
-
- // count=0,index=1, diff=2
- // count=0,index=5, diff=6
- // count=1,index=2, diff=2
- int diff = index - count + 1;
- while (diff > 0) {
- addView(inflater.inflate(R.layout.view_table_entry_row, this, false));
- diff -= 1;
- }
- }
-
- return (ViewGroup) getChildAt(index);
- }
-
- @NonNull
- private TextView ensureCell(@NonNull ViewGroup group, int index) {
-
- final int count = group.getChildCount();
- if (index >= count) {
- int diff = index - count + 1;
- while (diff > 0) {
- group.addView(inflater.inflate(R.layout.view_table_entry_cell, group, false));
- diff -= 1;
- }
- }
-
- return (TextView) group.getChildAt(index);
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- final int rows = getChildCount();
- if (rows == 0) {
- return;
- }
-
- // first draw the whole border
- rect.set(0, 0, getWidth(), getHeight());
- canvas.drawRect(rect, paint);
-
- ViewGroup group;
- View view;
-
- int top;
-
- for (int row = 0; row < rows; row++) {
- group = (ViewGroup) getChildAt(row);
- top = group.getTop();
- for (int col = 0, cols = group.getChildCount(); col < cols; col++) {
- view = group.getChildAt(col);
- rect.set(view.getLeft(), top + view.getTop(), view.getRight(), top + view.getBottom());
- canvas.drawRect(rect, paint);
- }
- }
- }
-
- private static int textAlignment(@NonNull Table.Alignment alignment) {
- final int out;
- switch (alignment) {
- case LEFT:
- out = TextView.TEXT_ALIGNMENT_TEXT_START;
- break;
- case CENTER:
- out = TextView.TEXT_ALIGNMENT_CENTER;
- break;
- case RIGHT:
- out = TextView.TEXT_ALIGNMENT_TEXT_END;
- break;
- default:
- throw new IllegalStateException("Unexpected alignment: " + alignment);
- }
- return out;
- }
-}
diff --git a/sample-custom-extension/src/main/res/layout/activity_recycler.xml b/sample-custom-extension/src/main/res/layout/activity_recycler.xml
deleted file mode 100644
index 1405e07c..00000000
--- a/sample-custom-extension/src/main/res/layout/activity_recycler.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/layout/adapter_default_entry.xml b/sample-custom-extension/src/main/res/layout/adapter_default_entry.xml
deleted file mode 100644
index 1d302e96..00000000
--- a/sample-custom-extension/src/main/res/layout/adapter_default_entry.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/layout/adapter_fenced_code_block.xml b/sample-custom-extension/src/main/res/layout/adapter_fenced_code_block.xml
deleted file mode 100644
index ddc2c802..00000000
--- a/sample-custom-extension/src/main/res/layout/adapter_fenced_code_block.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/layout/adapter_table_block.xml b/sample-custom-extension/src/main/res/layout/adapter_table_block.xml
deleted file mode 100644
index 287a6b9a..00000000
--- a/sample-custom-extension/src/main/res/layout/adapter_table_block.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/layout/view_table_entry_cell.xml b/sample-custom-extension/src/main/res/layout/view_table_entry_cell.xml
deleted file mode 100644
index 88654d3d..00000000
--- a/sample-custom-extension/src/main/res/layout/view_table_entry_cell.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/layout/view_table_entry_row.xml b/sample-custom-extension/src/main/res/layout/view_table_entry_row.xml
deleted file mode 100644
index 24e7fb9e..00000000
--- a/sample-custom-extension/src/main/res/layout/view_table_entry_row.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/values/attrs.xml b/sample-custom-extension/src/main/res/values/attrs.xml
deleted file mode 100644
index 5ee8b42b..00000000
--- a/sample-custom-extension/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-custom-extension/src/main/res/values/strings.xml b/sample-custom-extension/src/main/res/values/strings.xml
deleted file mode 100644
index fdc01039..00000000
--- a/sample-custom-extension/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
- Markwon-SampleCustomExtension
-
-
-
-
-
diff --git a/sample-custom-extension/src/main/res/values/styles.xml b/sample-custom-extension/src/main/res/values/styles.xml
deleted file mode 100644
index 49c8cb25..00000000
--- a/sample-custom-extension/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/sample-latex-math/build.gradle b/sample-latex-math/build.gradle
deleted file mode 100644
index cc381fa4..00000000
--- a/sample-latex-math/build.gradle
+++ /dev/null
@@ -1,24 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
-
- compileSdkVersion config['compile-sdk']
- buildToolsVersion config['build-tools']
-
- defaultConfig {
-
- applicationId "ru.noties.markwon.sample.jlatexmath"
-
- minSdkVersion config['min-sdk']
- targetSdkVersion config['target-sdk']
- versionCode 1
- versionName version
- }
-}
-
-dependencies {
- implementation project(':markwon-core')
- implementation project(':markwon-ext-latex')
-// implementation project(':markwon-image-loader')
-// implementation 'ru.noties:jlatexmath-android:0.1.0'
-}
diff --git a/sample-latex-math/src/main/AndroidManifest.xml b/sample-latex-math/src/main/AndroidManifest.xml
deleted file mode 100644
index 327ca324..00000000
--- a/sample-latex-math/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-latex-math/src/main/java/ru/noties/markwon/sample/jlatexmath/MainActivity.java b/sample-latex-math/src/main/java/ru/noties/markwon/sample/jlatexmath/MainActivity.java
deleted file mode 100644
index 7eeb8006..00000000
--- a/sample-latex-math/src/main/java/ru/noties/markwon/sample/jlatexmath/MainActivity.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package ru.noties.markwon.sample.jlatexmath;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.TextView;
-
-import ru.noties.markwon.Markwon;
-import ru.noties.markwon.core.CorePlugin;
-import ru.noties.markwon.ext.latex.JLatexMathPlugin;
-import ru.noties.markwon.image.ImagesPlugin;
-
-public class MainActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- final TextView textView = findViewById(R.id.text_view);
-
- String latex = "\\begin{array}{l}";
- latex += "\\forall\\varepsilon\\in\\mathbb{R}_+^*\\ \\exists\\eta>0\\ |x-x_0|\\leq\\eta\\Longrightarrow|f(x)-f(x_0)|\\leq\\varepsilon\\\\";
- latex += "\\det\\begin{bmatrix}a_{11}&a_{12}&\\cdots&a_{1n}\\\\a_{21}&\\ddots&&\\vdots\\\\\\vdots&&\\ddots&\\vdots\\\\a_{n1}&\\cdots&\\cdots&a_{nn}\\end{bmatrix}\\overset{\\mathrm{def}}{=}\\sum_{\\sigma\\in\\mathfrak{S}_n}\\varepsilon(\\sigma)\\prod_{k=1}^n a_{k\\sigma(k)}\\\\";
- latex += "\\sideset{_\\alpha^\\beta}{_\\gamma^\\delta}{\\begin{pmatrix}a&b\\\\c&d\\end{pmatrix}}\\\\";
- latex += "\\int_0^\\infty{x^{2n} e^{-a x^2}\\,dx} = \\frac{2n-1}{2a} \\int_0^\\infty{x^{2(n-1)} e^{-a x^2}\\,dx} = \\frac{(2n-1)!!}{2^{n+1}} \\sqrt{\\frac{\\pi}{a^{2n+1}}}\\\\";
- latex += "\\int_a^b{f(x)\\,dx} = (b - a) \\sum\\limits_{n = 1}^\\infty {\\sum\\limits_{m = 1}^{2^n - 1} {\\left( { - 1} \\right)^{m + 1} } } 2^{ - n} f(a + m\\left( {b - a} \\right)2^{-n} )\\\\";
- latex += "\\int_{-\\pi}^{\\pi} \\sin(\\alpha x) \\sin^n(\\beta x) dx = \\textstyle{\\left \\{ \\begin{array}{cc} (-1)^{(n+1)/2} (-1)^m \\frac{2 \\pi}{2^n} \\binom{n}{m} & n \\mbox{ odd},\\ \\alpha = \\beta (2m-n) \\\\ 0 & \\mbox{otherwise} \\\\ \\end{array} \\right .}\\\\";
- latex += "L = \\int_a^b \\sqrt{ \\left|\\sum_{i,j=1}^ng_{ij}(\\gamma(t))\\left(\\frac{d}{dt}x^i\\circ\\gamma(t)\\right)\\left(\\frac{d}{dt}x^j\\circ\\gamma(t)\\right)\\right|}\\,dt\\\\";
- latex += "\\begin{array}{rl} s &= \\int_a^b\\left\\|\\frac{d}{dt}\\vec{r}\\,(u(t),v(t))\\right\\|\\,dt \\\\ &= \\int_a^b \\sqrt{u'(t)^2\\,\\vec{r}_u\\cdot\\vec{r}_u + 2u'(t)v'(t)\\, \\vec{r}_u\\cdot\\vec{r}_v+ v'(t)^2\\,\\vec{r}_v\\cdot\\vec{r}_v}\\,\\,\\, dt. \\end{array}\\\\";
- latex += "\\end{array}";
-
-// String latex = "\\text{A long division \\longdiv{12345}{13}";
-// String latex = "{a \\bangle b} {c \\brace d} {e \\brack f} {g \\choose h}";
-
-// String latex = "\\begin{array}{cc}";
-// latex += "\\fbox{\\text{A framed box with \\textdbend}}&\\shadowbox{\\text{A shadowed box}}\\cr";
-// latex += "\\doublebox{\\text{A double framed box}}&\\ovalbox{\\text{An oval framed box}}\\cr";
-// latex += "\\end{array}";
-
-
- final JLatexMathPlugin.Config config = new JLatexMathPlugin.Config(textView.getTextSize()) {{
-// align = JLatexMathDrawable.ALIGN_RIGHT;
- }};
-
- final String markdown = "# Example of LaTeX\n\n$$"
- + latex + "$$\n\n something like **this**";
-
- final Markwon markwon = Markwon.builder(this)
- .usePlugin(CorePlugin.create())
- // strictly speaking this one is not required as long as JLatexMathPlugin schedules
- // drawables on it's own
- .usePlugin(ImagesPlugin.create(this))
- .usePlugin(JLatexMathPlugin.create(config))
- .build();
-
- markwon.setMarkdown(textView, markdown);
- }
-}
diff --git a/sample-latex-math/src/main/res/layout/activity_main.xml b/sample-latex-math/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 23e9e463..00000000
--- a/sample-latex-math/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample-latex-math/src/main/res/values/strings.xml b/sample-latex-math/src/main/res/values/strings.xml
deleted file mode 100644
index 58b56912..00000000
--- a/sample-latex-math/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Markwon-JLatexMath
-
diff --git a/sample-latex-math/src/main/res/values/styles.xml b/sample-latex-math/src/main/res/values/styles.xml
deleted file mode 100644
index b0e65b65..00000000
--- a/sample-latex-math/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
diff --git a/sample/build.gradle b/sample/build.gradle
index 2ee3691a..35db7389 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -42,6 +42,7 @@ android {
dependencies {
implementation project(':markwon-core')
+ implementation project(':markwon-ext-latex')
implementation project(':markwon-ext-strikethrough')
implementation project(':markwon-ext-tables')
implementation project(':markwon-ext-tasklist')
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index cbccca0d..732928be 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -25,6 +25,7 @@
+
diff --git a/sample/src/main/java/ru/noties/markwon/sample/customextension/CustomExtensionActivity.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/CustomExtensionActivity.java
index 1b35c0c7..4a9c2fd9 100644
--- a/sample/src/main/java/ru/noties/markwon/sample/customextension/CustomExtensionActivity.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/CustomExtensionActivity.java
@@ -1,6 +1,36 @@
package ru.noties.markwon.sample.customextension;
import android.app.Activity;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.widget.TextView;
+
+import ru.noties.markwon.Markwon;
+import ru.noties.markwon.image.ImagesPlugin;
+import ru.noties.markwon.sample.R;
public class CustomExtensionActivity extends Activity {
+
+ // please note that this sample won't work on a device with SDK level < 21
+ // as we are using vector drawables for the sake of brevity. Other than resources
+ // used, this is fully functional sample on all SDK levels
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_text_view);
+
+ final TextView textView = findViewById(R.id.text_view);
+
+ // note that we haven't registered CorePlugin, as it's the only one that can be
+ // implicitly deducted and added automatically. All other plugins require explicit
+ // `usePlugin` call
+ final Markwon markwon = Markwon.builder(this)
+ // try commenting out this line to see runtime dependency resolution
+ .usePlugin(ImagesPlugin.create(this))
+ .usePlugin(IconPlugin.create(IconSpanProvider.create(this, 0)))
+ .build();
+
+ markwon.setMarkdown(textView, getString(R.string.input));
+ }
}
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconGroupNode.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconGroupNode.java
similarity index 71%
rename from sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconGroupNode.java
rename to sample/src/main/java/ru/noties/markwon/sample/customextension/IconGroupNode.java
index 193b33b8..98560b49 100644
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconGroupNode.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconGroupNode.java
@@ -1,4 +1,4 @@
-package ru.noties.markwon.sample.extension;
+package ru.noties.markwon.sample.customextension;
import org.commonmark.node.CustomNode;
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconNode.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconNode.java
similarity index 96%
rename from sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconNode.java
rename to sample/src/main/java/ru/noties/markwon/sample/customextension/IconNode.java
index 3d40ec2f..b297e4a6 100644
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconNode.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconNode.java
@@ -1,4 +1,4 @@
-package ru.noties.markwon.sample.extension;
+package ru.noties.markwon.sample.customextension;
import android.support.annotation.NonNull;
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconPlugin.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconPlugin.java
similarity index 85%
rename from sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconPlugin.java
rename to sample/src/main/java/ru/noties/markwon/sample/customextension/IconPlugin.java
index eb821000..3de96315 100644
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconPlugin.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconPlugin.java
@@ -1,4 +1,4 @@
-package ru.noties.markwon.sample.extension;
+package ru.noties.markwon.sample.customextension;
import android.support.annotation.NonNull;
import android.text.TextUtils;
@@ -7,6 +7,8 @@ import org.commonmark.parser.Parser;
import ru.noties.markwon.AbstractMarkwonPlugin;
import ru.noties.markwon.MarkwonVisitor;
+import ru.noties.markwon.image.ImagesPlugin;
+import ru.noties.markwon.priority.Priority;
public class IconPlugin extends AbstractMarkwonPlugin {
@@ -21,6 +23,13 @@ public class IconPlugin extends AbstractMarkwonPlugin {
this.iconSpanProvider = iconSpanProvider;
}
+ @NonNull
+ @Override
+ public Priority priority() {
+ // define images dependency
+ return Priority.after(ImagesPlugin.class);
+ }
+
@Override
public void configureParser(@NonNull Parser.Builder builder) {
builder.customDelimiterProcessor(IconProcessor.create());
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconProcessor.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconProcessor.java
similarity index 98%
rename from sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconProcessor.java
rename to sample/src/main/java/ru/noties/markwon/sample/customextension/IconProcessor.java
index 500726e0..eb7a79be 100644
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconProcessor.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconProcessor.java
@@ -1,4 +1,4 @@
-package ru.noties.markwon.sample.extension;
+package ru.noties.markwon.sample.customextension;
import android.support.annotation.NonNull;
import android.text.TextUtils;
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconSpan.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconSpan.java
similarity index 97%
rename from sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconSpan.java
rename to sample/src/main/java/ru/noties/markwon/sample/customextension/IconSpan.java
index 690ba5b2..9d2b8b43 100644
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconSpan.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconSpan.java
@@ -1,4 +1,4 @@
-package ru.noties.markwon.sample.extension;
+package ru.noties.markwon.sample.customextension;
import android.graphics.Canvas;
import android.graphics.Paint;
diff --git a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconSpanProvider.java b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconSpanProvider.java
similarity index 97%
rename from sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconSpanProvider.java
rename to sample/src/main/java/ru/noties/markwon/sample/customextension/IconSpanProvider.java
index cd6e3bf3..25049bc2 100644
--- a/sample-custom-extension/src/main/java/ru/noties/markwon/sample/extension/IconSpanProvider.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/customextension/IconSpanProvider.java
@@ -1,4 +1,4 @@
-package ru.noties.markwon.sample.extension;
+package ru.noties.markwon.sample.customextension;
import android.content.Context;
import android.content.res.Resources;
diff --git a/sample/src/main/java/ru/noties/markwon/sample/latex/LatexActivity.java b/sample/src/main/java/ru/noties/markwon/sample/latex/LatexActivity.java
index 179113ea..6e7bd938 100644
--- a/sample/src/main/java/ru/noties/markwon/sample/latex/LatexActivity.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/latex/LatexActivity.java
@@ -3,6 +3,13 @@ package ru.noties.markwon.sample.latex;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
+import android.widget.TextView;
+
+import ru.noties.markwon.Markwon;
+import ru.noties.markwon.core.CorePlugin;
+import ru.noties.markwon.ext.latex.JLatexMathPlugin;
+import ru.noties.markwon.image.ImagesPlugin;
+import ru.noties.markwon.sample.R;
public class LatexActivity extends Activity {
@@ -10,6 +17,42 @@ public class LatexActivity extends Activity {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_text_view);
+ final TextView textView = findViewById(R.id.text_view);
+
+ String latex = "\\begin{array}{l}";
+ latex += "\\forall\\varepsilon\\in\\mathbb{R}_+^*\\ \\exists\\eta>0\\ |x-x_0|\\leq\\eta\\Longrightarrow|f(x)-f(x_0)|\\leq\\varepsilon\\\\";
+ latex += "\\det\\begin{bmatrix}a_{11}&a_{12}&\\cdots&a_{1n}\\\\a_{21}&\\ddots&&\\vdots\\\\\\vdots&&\\ddots&\\vdots\\\\a_{n1}&\\cdots&\\cdots&a_{nn}\\end{bmatrix}\\overset{\\mathrm{def}}{=}\\sum_{\\sigma\\in\\mathfrak{S}_n}\\varepsilon(\\sigma)\\prod_{k=1}^n a_{k\\sigma(k)}\\\\";
+ latex += "\\sideset{_\\alpha^\\beta}{_\\gamma^\\delta}{\\begin{pmatrix}a&b\\\\c&d\\end{pmatrix}}\\\\";
+ latex += "\\int_0^\\infty{x^{2n} e^{-a x^2}\\,dx} = \\frac{2n-1}{2a} \\int_0^\\infty{x^{2(n-1)} e^{-a x^2}\\,dx} = \\frac{(2n-1)!!}{2^{n+1}} \\sqrt{\\frac{\\pi}{a^{2n+1}}}\\\\";
+ latex += "\\int_a^b{f(x)\\,dx} = (b - a) \\sum\\limits_{n = 1}^\\infty {\\sum\\limits_{m = 1}^{2^n - 1} {\\left( { - 1} \\right)^{m + 1} } } 2^{ - n} f(a + m\\left( {b - a} \\right)2^{-n} )\\\\";
+ latex += "\\int_{-\\pi}^{\\pi} \\sin(\\alpha x) \\sin^n(\\beta x) dx = \\textstyle{\\left \\{ \\begin{array}{cc} (-1)^{(n+1)/2} (-1)^m \\frac{2 \\pi}{2^n} \\binom{n}{m} & n \\mbox{ odd},\\ \\alpha = \\beta (2m-n) \\\\ 0 & \\mbox{otherwise} \\\\ \\end{array} \\right .}\\\\";
+ latex += "L = \\int_a^b \\sqrt{ \\left|\\sum_{i,j=1}^ng_{ij}(\\gamma(t))\\left(\\frac{d}{dt}x^i\\circ\\gamma(t)\\right)\\left(\\frac{d}{dt}x^j\\circ\\gamma(t)\\right)\\right|}\\,dt\\\\";
+ latex += "\\begin{array}{rl} s &= \\int_a^b\\left\\|\\frac{d}{dt}\\vec{r}\\,(u(t),v(t))\\right\\|\\,dt \\\\ &= \\int_a^b \\sqrt{u'(t)^2\\,\\vec{r}_u\\cdot\\vec{r}_u + 2u'(t)v'(t)\\, \\vec{r}_u\\cdot\\vec{r}_v+ v'(t)^2\\,\\vec{r}_v\\cdot\\vec{r}_v}\\,\\,\\, dt. \\end{array}\\\\";
+ latex += "\\end{array}";
+
+// String latex = "\\text{A long division \\longdiv{12345}{13}";
+// String latex = "{a \\bangle b} {c \\brace d} {e \\brack f} {g \\choose h}";
+
+// String latex = "\\begin{array}{cc}";
+// latex += "\\fbox{\\text{A framed box with \\textdbend}}&\\shadowbox{\\text{A shadowed box}}\\cr";
+// latex += "\\doublebox{\\text{A double framed box}}&\\ovalbox{\\text{An oval framed box}}\\cr";
+// latex += "\\end{array}";
+
+
+ final JLatexMathPlugin.Config config = new JLatexMathPlugin.Config(textView.getTextSize()) {{
+// align = JLatexMathDrawable.ALIGN_RIGHT;
+ }};
+
+ final String markdown = "# Example of LaTeX\n\n$$"
+ + latex + "$$\n\n something like **this**";
+
+ final Markwon markwon = Markwon.builder(this)
+ .usePlugin(ImagesPlugin.create(this))
+ .usePlugin(JLatexMathPlugin.create(config))
+ .build();
+
+ markwon.setMarkdown(textView, markdown);
}
}
diff --git a/sample/src/main/java/ru/noties/markwon/sample/recycler/RecyclerActivity.java b/sample/src/main/java/ru/noties/markwon/sample/recycler/RecyclerActivity.java
index 53232393..47afb7bd 100644
--- a/sample/src/main/java/ru/noties/markwon/sample/recycler/RecyclerActivity.java
+++ b/sample/src/main/java/ru/noties/markwon/sample/recycler/RecyclerActivity.java
@@ -31,6 +31,7 @@ import ru.noties.markwon.image.svg.SvgPlugin;
import ru.noties.markwon.recycler.MarkwonAdapter;
import ru.noties.markwon.recycler.SimpleEntry;
import ru.noties.markwon.sample.R;
+import ru.noties.markwon.syntax.SyntaxHighlightPlugin;
import ru.noties.markwon.urlprocessor.UrlProcessor;
import ru.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
diff --git a/sample/src/main/java/ru/noties/markwon/sample/theme/ThemeActivity.java b/sample/src/main/java/ru/noties/markwon/sample/theme/ThemeActivity.java
new file mode 100644
index 00000000..33ee500a
--- /dev/null
+++ b/sample/src/main/java/ru/noties/markwon/sample/theme/ThemeActivity.java
@@ -0,0 +1,17 @@
+package ru.noties.markwon.sample.theme;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+
+import ru.noties.markwon.sample.R;
+
+public class ThemeActivity extends Activity {
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_text_view);
+ }
+}
diff --git a/sample-custom-extension/src/main/res/drawable/ic_android_black_24dp.xml b/sample/src/main/res/drawable/ic_android_black_24dp.xml
similarity index 100%
rename from sample-custom-extension/src/main/res/drawable/ic_android_black_24dp.xml
rename to sample/src/main/res/drawable/ic_android_black_24dp.xml
diff --git a/sample-custom-extension/src/main/res/drawable/ic_home_black_36dp.xml b/sample/src/main/res/drawable/ic_home_black_36dp.xml
similarity index 100%
rename from sample-custom-extension/src/main/res/drawable/ic_home_black_36dp.xml
rename to sample/src/main/res/drawable/ic_home_black_36dp.xml
diff --git a/sample-custom-extension/src/main/res/drawable/ic_memory_black_48dp.xml b/sample/src/main/res/drawable/ic_memory_black_48dp.xml
similarity index 100%
rename from sample-custom-extension/src/main/res/drawable/ic_memory_black_48dp.xml
rename to sample/src/main/res/drawable/ic_memory_black_48dp.xml
diff --git a/sample-custom-extension/src/main/res/drawable/ic_sentiment_satisfied_red_64dp.xml b/sample/src/main/res/drawable/ic_sentiment_satisfied_red_64dp.xml
similarity index 100%
rename from sample-custom-extension/src/main/res/drawable/ic_sentiment_satisfied_red_64dp.xml
rename to sample/src/main/res/drawable/ic_sentiment_satisfied_red_64dp.xml
diff --git a/sample-custom-extension/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_text_view.xml
similarity index 71%
rename from sample-custom-extension/src/main/res/layout/activity_main.xml
rename to sample/src/main/res/layout/activity_text_view.xml
index e4f2a936..3eaf3c62 100644
--- a/sample-custom-extension/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_text_view.xml
@@ -1,6 +1,4 @@
-
-
@@ -12,6 +10,6 @@
android:padding="8dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
- tools:text="@string/input"/>
+ tools:text="whatever" />
-
+
\ No newline at end of file
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 0081dfc7..d1ec3ddc 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -1,3 +1,14 @@
+
MarkwonSample
+
+
+
+
diff --git a/settings.gradle b/settings.gradle
index 8bc72bd1..e3177a74 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -11,6 +11,4 @@ include ':app', ':sample',
':markwon-image-svg',
':markwon-recycler',
':markwon-syntax-highlight',
- ':markwon-test-span',
- ':sample-custom-extension',
- ':sample-latex-math'
+ ':markwon-test-span'