mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +03:00
Add Markdown -> HTML transform (#82)
* Fix #80: Add Markdown to HTML transform * Fix precommit for node v10
This commit is contained in:
1 parent
6633156e1b
commit
c3a3a892dd
4 files changed
+100
-8
No files matched your search
+2
-1
@@ -53,6 +53,7 @@
|
||||
"json2yaml": "^1.1.0",
|
||||
"jsx-to-json": "^0.2.3",
|
||||
"lodash": "^4.17.4",
|
||||
"markdown": "^0.5.0",
|
||||
"next": "6.0.0-canary.6",
|
||||
"nprogress": "^0.2.0",
|
||||
"promise-worker": "^1.1.1",
|
||||
@@ -84,7 +85,7 @@
|
||||
"css-loader": "^0.28.7",
|
||||
"glob": "^7.1.2",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.0.4",
|
||||
"lint-staged": "^7.0.5",
|
||||
"lodash-webpack-plugin": "^0.11.5",
|
||||
"prettier": "^1.12.1",
|
||||
"style-loader": "^0.21.0",
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import React, { Fragment, PureComponent } from "react";
|
||||
import ConversionPanel from "../components/ConversionPanel";
|
||||
import PoweredBy from "../components/PoweredBy";
|
||||
import { markdown } from "markdown";
|
||||
|
||||
// Example text from https://en.wikipedia.org/wiki/Markdown#Example
|
||||
const defaultText = `Heading
|
||||
=======
|
||||
|
||||
## Sub-heading
|
||||
|
||||
Paragraphs are separated
|
||||
by a blank line.
|
||||
|
||||
Two spaces at the end of a line
|
||||
produces a line break.
|
||||
|
||||
Text attributes _italic_,
|
||||
**bold**, \`monospace\`.
|
||||
|
||||
Horizontal rule:
|
||||
|
||||
---
|
||||
|
||||
Bullet list:
|
||||
|
||||
* apples
|
||||
* oranges
|
||||
* pears
|
||||
|
||||
Numbered list:
|
||||
|
||||
1. wash
|
||||
2. rinse
|
||||
3. repeat
|
||||
|
||||
A [link](http://example.com).
|
||||
|
||||

|
||||
|
||||
> Markdown uses email-style > characters for blockquoting.
|
||||
|
||||
Inline <abbr title="Hypertext Markup Language">HTML</abbr> is supported.
|
||||
`;
|
||||
|
||||
export default class extends PureComponent {
|
||||
getTransformedValue = text => markdown.toHTML(text);
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Fragment>
|
||||
<ConversionPanel
|
||||
leftTitle="Markdown"
|
||||
rightTitle="HTML"
|
||||
getTransformedValue={this.getTransformedValue}
|
||||
defaultText={defaultText}
|
||||
leftMode="markdown"
|
||||
rightMode="html"
|
||||
url={this.props.url}
|
||||
/>
|
||||
<PoweredBy pathname={this.props.url.pathname} />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -235,6 +235,13 @@ export const categorizedRoutes = [
|
||||
desc: "An online REPL to convert YAML to JSON.",
|
||||
packageName: "yaml",
|
||||
packageUrl: "https://github.com/tj/js-yaml"
|
||||
},
|
||||
{
|
||||
label: "Markdown to HTML",
|
||||
path: "/markdown-to-html",
|
||||
desc: "An online REPL to convert Markdown to HTML.",
|
||||
packageName: "markdown",
|
||||
packageUrl: "https://github.com/evilstreak/markdown-js"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4929,9 +4929,9 @@ lie@^3.0.2:
|
||||
dependencies:
|
||||
immediate "~3.0.5"
|
||||
|
||||
lint-staged@^7.0.4:
|
||||
version "7.0.4"
|
||||
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-7.0.4.tgz#1aa7f27427e4c4c85d4d6524ac98aac10cbaf1b8"
|
||||
lint-staged@^7.0.5:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-7.1.0.tgz#1514a5b71b8d9492ca0c3d2a44769cbcbc8bcc79"
|
||||
dependencies:
|
||||
app-root-path "^2.0.1"
|
||||
chalk "^2.3.1"
|
||||
@@ -4942,6 +4942,7 @@ lint-staged@^7.0.4:
|
||||
execa "^0.9.0"
|
||||
find-parent-dir "^0.3.0"
|
||||
is-glob "^4.0.0"
|
||||
is-windows "^1.0.2"
|
||||
jest-validate "^22.4.0"
|
||||
listr "^0.13.0"
|
||||
lodash "^4.17.5"
|
||||
@@ -4951,7 +4952,7 @@ lint-staged@^7.0.4:
|
||||
p-map "^1.1.1"
|
||||
path-is-inside "^1.0.2"
|
||||
pify "^3.0.0"
|
||||
please-upgrade-node "^3.0.1"
|
||||
please-upgrade-node "^3.0.2"
|
||||
staged-git-files "1.1.1"
|
||||
string-argv "^0.0.2"
|
||||
stringify-object "^3.2.2"
|
||||
@@ -5206,6 +5207,12 @@ map-visit@^1.0.0:
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
markdown@^0.5.0:
|
||||
version "0.5.0"
|
||||
resolved "https://registry.yarnpkg.com/markdown/-/markdown-0.5.0.tgz#28205b565a8ae7592de207463d6637dc182722b2"
|
||||
dependencies:
|
||||
nopt "~2.1.1"
|
||||
|
||||
math-expression-evaluator@^1.2.14:
|
||||
version "1.2.17"
|
||||
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac"
|
||||
@@ -5617,6 +5624,12 @@ nopt@~1.0.10:
|
||||
dependencies:
|
||||
abbrev "1"
|
||||
|
||||
nopt@~2.1.1:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/nopt/-/nopt-2.1.2.tgz#6cccd977b80132a07731d6e8ce58c2c8303cf9af"
|
||||
dependencies:
|
||||
abbrev "1"
|
||||
|
||||
nopt@~3.0.1:
|
||||
version "3.0.6"
|
||||
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
|
||||
@@ -6057,9 +6070,11 @@ pkg-dir@^2.0.0:
|
||||
dependencies:
|
||||
find-up "^2.1.0"
|
||||
|
||||
please-upgrade-node@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.0.1.tgz#0a681f2c18915e5433a5ca2cd94e0b8206a782db"
|
||||
please-upgrade-node@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.0.2.tgz#7b9eaeca35aa4a43d6ebdfd10616c042f9a83acc"
|
||||
dependencies:
|
||||
semver-compare "^1.0.0"
|
||||
|
||||
pn@^1.1.0:
|
||||
version "1.1.0"
|
||||
@@ -7107,6 +7122,10 @@ schema-utils@^0.4.0, schema-utils@^0.4.2, schema-utils@^0.4.5:
|
||||
ajv "^6.1.0"
|
||||
ajv-keywords "^3.1.0"
|
||||
|
||||
semver-compare@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"
|
||||
|
||||
semver-diff@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36"
|
||||
|
||||
Reference in new issue
Block a user