Started working with standalone doc site
This commit is contained in:
parent
c7c998db8f
commit
d382b37a72
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,4 +5,6 @@
|
||||
.DS_Store
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
**/build
|
||||
**/build
|
||||
**/dist
|
||||
**/node_modules
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Markwon
|
||||
|
||||
<i>
|
||||
& © † ‡
|
||||
|
||||
[](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)
|
||||
|
@ -13,6 +13,7 @@ import java.util.concurrent.Future;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import ru.noties.debug.Debug;
|
||||
import ru.noties.markwon.html.api.MarkwonHtmlParser;
|
||||
import ru.noties.markwon.spans.AsyncDrawable;
|
||||
import ru.noties.markwon.spans.SpannableTheme;
|
||||
import ru.noties.markwon.syntax.Prism4jSyntaxHighlight;
|
||||
@ -97,6 +98,7 @@ public class MarkdownRenderer {
|
||||
.build())
|
||||
.factory(new GifAwareSpannableFactory(gifPlaceholder))
|
||||
.trimWhiteSpaceEnd(false)
|
||||
.htmlParser(MarkwonHtmlParser.noOp())
|
||||
.build();
|
||||
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
|
34
docs/.vuepress/components/GithubIssue.vue
Normal file
34
docs/.vuepress/components/GithubIssue.vue
Normal file
@ -0,0 +1,34 @@
|
||||
<template>
|
||||
<a :href="githubIssueHref">{{linkContent}}</a>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "GithubIssue",
|
||||
props: {
|
||||
id: {
|
||||
required: true
|
||||
},
|
||||
displayName: { required: false },
|
||||
user: {
|
||||
default: "noties",
|
||||
required: false
|
||||
},
|
||||
repo: {
|
||||
default: "Markwon",
|
||||
required: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
githubIssueHref: function() {
|
||||
return (
|
||||
"https://github.com/" + this.user + "/" + this.repo + "/issues/" + this.id
|
||||
);
|
||||
},
|
||||
linkContent: function() {
|
||||
return this.displayName || "#" + this.id;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
42
docs/.vuepress/components/Link.vue
Normal file
42
docs/.vuepress/components/Link.vue
Normal file
@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<a :href="linkHref()" v-text="linkText()"></a>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var map = {
|
||||
"commonmark-spec": {
|
||||
displayName: "commonmark spec",
|
||||
href: "https://spec.commonmark.org/0.28/"
|
||||
},
|
||||
"commonmark-spec#inline": {
|
||||
href: "https://spec.commonmark.org/0.28/#raw-html"
|
||||
},
|
||||
"commonmark-spec#block": {
|
||||
href: "https://spec.commonmark.org/0.28/#html-blocks"
|
||||
},
|
||||
"commonmark-dingus": {
|
||||
displayName: "commonmark dingus",
|
||||
href: "https://spec.commonmark.org/dingus/"
|
||||
},
|
||||
"html-inlines": {
|
||||
href: "https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements"
|
||||
},
|
||||
"html-blocks": {
|
||||
href: "https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements"
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "Link",
|
||||
props: ["name", "displayName", "href"],
|
||||
methods: {
|
||||
linkHref: function() {
|
||||
return this.href || map[this.name].href;
|
||||
},
|
||||
linkText: function() {
|
||||
return this.displayName || map[this.name].displayName;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
19
docs/.vuepress/components/MavenBadge.vue
Normal file
19
docs/.vuepress/components/MavenBadge.vue
Normal file
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<a :href="mavenSearchUrl()"><img :src="shieldImgageUrl()" :alt="'' + artifact"></a>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'MavenBadge',
|
||||
props: ['artifact'],
|
||||
methods: {
|
||||
mavenSearchUrl: function() {
|
||||
return 'http://search.maven.org/#search|ga|1|g%3A%22ru.noties%22%20AND%20a%3A%22' + this.artifact + '%22';
|
||||
},
|
||||
shieldImgageUrl: function() {
|
||||
return 'https://img.shields.io/maven-central/v/ru.noties/' + this.artifact +'.svg?label=' + this.artifact;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
20
docs/.vuepress/components/MavenBadges.vue
Normal file
20
docs/.vuepress/components/MavenBadges.vue
Normal file
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<MavenBadge :artifact="'markwon'" />
|
||||
<MavenBadge :artifact="'markwon-image-loader'" />
|
||||
<MavenBadge :artifact="'markwon-syntax-highlight'"/>
|
||||
<MavenBadge :artifact="'markwon-view'"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MavenBadge from "./MavenBadge.vue";
|
||||
export default {
|
||||
name: "MavenBadges",
|
||||
components: {
|
||||
MavenBadge
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
23
docs/.vuepress/config.js
Normal file
23
docs/.vuepress/config.js
Normal file
@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
base: '/Markwon/',
|
||||
title: 'Markwon',
|
||||
description: 'Android markdown library based on commonmark specification',
|
||||
head: [
|
||||
['link', {rel: 'icon', href: '/favicon.png'}]
|
||||
],
|
||||
themeConfig: {
|
||||
nav: [
|
||||
{ text: 'Install', link: '/docs/install.md' },
|
||||
{ text: 'Github', link: 'https://github.com/noties/Markwon' }
|
||||
],
|
||||
sidebar: [
|
||||
'/',
|
||||
'/docs/getting-started.md',
|
||||
'/docs/configure.md',
|
||||
'/docs/html.md',
|
||||
'/docs/syntax-highlight.md',
|
||||
'/docs/image-loader.md',
|
||||
'/docs/view.md'
|
||||
]
|
||||
}
|
||||
}
|
2
docs/.vuepress/override.styl
Normal file
2
docs/.vuepress/override.styl
Normal file
@ -0,0 +1,2 @@
|
||||
$textColor = #000000
|
||||
$accentColor = #4CAF50
|
1
docs/.vuepress/public/art
Symbolic link
1
docs/.vuepress/public/art
Symbolic link
@ -0,0 +1 @@
|
||||
../../../art/
|
24
docs/README.md
Normal file
24
docs/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
title: 'Overview'
|
||||
---
|
||||
|
||||
<img :src="$withBase('./art/markwon_logo.png')" alt="Markwon Logo" width="50%">
|
||||
|
||||
<br><br>
|
||||
<MavenBadges/>
|
||||
|
||||
**Markwon** is a markdown library for Android. It parses markdown
|
||||
following [commonmark spec] with the help
|
||||
of amazing [commonmark-java](https://github.com/atlassian/commonmark-java/) library
|
||||
and renders result as _Android-native_ Spannables. **No HTML** is involved
|
||||
as an intermediate step. <u>**No WebView** is required</u>. 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/
|
19
docs/deploy.sh
Normal file
19
docs/deploy.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# abort on errors
|
||||
set -e
|
||||
|
||||
# build
|
||||
npm run docs:build
|
||||
|
||||
# navigate into the build output directory
|
||||
cd .vuepress/dist
|
||||
|
||||
git init
|
||||
git add -A
|
||||
git commit -m 'deploy'
|
||||
|
||||
# if you are deploying to https://<USERNAME>.github.io/<REPO>
|
||||
git push -f git@github.com:noties/Markwon.git master:gh-pages
|
||||
|
||||
cd -
|
1
docs/docs/configure.md
Normal file
1
docs/docs/configure.md
Normal file
@ -0,0 +1 @@
|
||||
# Configuration
|
6
docs/docs/getting-started.md
Normal file
6
docs/docs/getting-started.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Getting started
|
||||
|
||||
:::tip Installation
|
||||
Please follow [installation](/docs/install.md) section instructions
|
||||
to learn how to add `Markwon` to your project
|
||||
:::
|
114
docs/docs/html.md
Normal file
114
docs/docs/html.md
Normal file
@ -0,0 +1,114 @@
|
||||
# HTML
|
||||
<Badge text="2.x.x" />
|
||||
|
||||
Starting with version `2.x.x` `Markwon` brings the whole HTML parsing/rendering
|
||||
stack _on-site_. The main reason for this are _special_ definitions of HTML nodes
|
||||
by <Link name="commonmark-spec" />. More specifically: <Link name="commonmark-spec#inline" displayName="inline" />
|
||||
and <Link name="commonmark-spec#block" displayName="block" />.
|
||||
These two are _a bit_ different from _native_ HTML understanding.
|
||||
Well, they are completely different and share only the same names as
|
||||
<Link name="html-inlines" displayName="HTML-inline"/> and <Link name="html-blocks" displayName="HTML-block"/>
|
||||
elements. This leads to situations when for example an `<i>` tag is considered
|
||||
a block when it's used like this:
|
||||
|
||||
```markdown
|
||||
<i>
|
||||
Hello from italics tag
|
||||
</i>
|
||||
```
|
||||
|
||||
:::tip A bit of background
|
||||
<br>
|
||||
<GithubIssue id="52" displayName="This issue" /> had brought attention to differences between HTML & commonmark implementations. <br><br>
|
||||
:::
|
||||
|
||||
Let's modify code snippet above _a bit_:
|
||||
|
||||
```markdown{3}
|
||||
<i>
|
||||
Hello from italics tag
|
||||
|
||||
</i>
|
||||
```
|
||||
|
||||
We have just added a `new-line` before closing `</i>` tag. And this
|
||||
changes everything as now, according to the <Link name="commonmark-dingus" />,
|
||||
we have 2 HtmlBlocks: one before `new-line` (containing open `<i>` tag and text content)
|
||||
and one after (containing as little as closing `</i>` tag).
|
||||
|
||||
If we modify code snippet _a bit_ again:
|
||||
|
||||
```markdown{4}
|
||||
<i>
|
||||
Hello from italics tag
|
||||
|
||||
</i><b>bold></b>
|
||||
```
|
||||
|
||||
We will have 1 HtmlBlock (from previous snippet) and a bunch of HtmlInlines:
|
||||
* HtmlInline (`<i>`)
|
||||
* HtmlInline (`<b>`)
|
||||
* Text (`bold`)
|
||||
* HtmlInline (`</b>`)
|
||||
|
||||
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 `<i>italic` fragment they will make it `<i>italic</i>`.
|
||||
And it's a good thing, but consider these fragments for the sake of markdown:
|
||||
|
||||
* `<i>italic `
|
||||
* `<b>bold italic`
|
||||
* `</b><i>`
|
||||
|
||||
We will get:
|
||||
|
||||
* `<i>italic </i>`
|
||||
* `<b>bold italic</b>`
|
||||
|
||||
_<sup>*</sup> Or to be precise: `<html><head></head><body><i>italic </i></body></html>` &
|
||||
`<html><head></head><body><b>bold italic</b></body></html>`_
|
||||
|
||||
Which will be rendered in a final document:
|
||||
|
||||
|
||||
|expected|actual|
|
||||
|---|---|
|
||||
|<i>italic <b>bold italic</b></i>|<i>italic </i><b>bold italic</b>|
|
||||
|
||||
This might seem like a minor problem, but add more tags to a document,
|
||||
introduce some deeply nested structures, spice openning and closing tags up
|
||||
by adding markdown markup between them and finally write _malicious_ HTML code :laughing:!
|
||||
|
||||
Because of this I
|
||||
|
||||
afterall creating an implementation of a web browser is not a purpose of this library.
|
||||
|
||||
html-entities
|
||||
|
||||
## 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`.
|
||||
|
||||
<MavenBadge :artifact="'markwon'" />
|
||||
|
||||
```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.
|
1
docs/docs/image-loader.md
Normal file
1
docs/docs/image-loader.md
Normal file
@ -0,0 +1 @@
|
||||
# Image loader
|
34
docs/docs/install.md
Normal file
34
docs/docs/install.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
prev: false
|
||||
next: /docs/getting-started.md
|
||||
---
|
||||
|
||||
# Installation
|
||||
|
||||
## Snapshot
|
||||
|
||||

|
||||
|
||||
In order to use latest `SNAPSHOT` version add snapshot repository
|
||||
to your root project's `build.gradle` file:
|
||||
|
||||
```groovy
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
and then in your module `build.gradle`:
|
||||
|
||||
```groovy
|
||||
implementation 'ru.noties:markwon:1.1.1-SNAPSHOT'
|
||||
```
|
||||
|
||||
Please note that `markwon-image-loader`, `markwon-syntax-highlight`
|
||||
and `markwon-view` are also present in `SNAPSHOT` repository and
|
||||
share the same version as main `markwon` artifact.
|
||||
|
1
docs/docs/syntax-highlight.md
Normal file
1
docs/docs/syntax-highlight.md
Normal file
@ -0,0 +1 @@
|
||||
# Syntax highlight
|
1
docs/docs/view.md
Normal file
1
docs/docs/view.md
Normal file
@ -0,0 +1 @@
|
||||
# View
|
10680
docs/package-lock.json
generated
Normal file
10680
docs/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
8
docs/package.json
Normal file
8
docs/package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"scripts": {
|
||||
"docs:build": "vuepress build"
|
||||
},
|
||||
"dependencies": {
|
||||
"vuepress": "^0.14.2"
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package ru.noties.markwon.renderer;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
|
||||
import org.commonmark.ext.gfm.strikethrough.Strikethrough;
|
||||
import org.commonmark.ext.gfm.tables.TableBody;
|
||||
@ -454,6 +455,7 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
||||
|
||||
private void visitHtml(@Nullable String html) {
|
||||
if (html != null) {
|
||||
Log.e("HTML", html);
|
||||
htmlParser.processFragment(builder, html);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user