Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_markdown.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-08-29 12:54:50 +0300
committerRobin Appelman <robin@icewind.nl>2017-08-29 12:54:50 +0300
commitcca550b7e9f883464e494ed8880aedd7fa753786 (patch)
treec22448a769474d24ea646f52314e1f6fbe14c450
parentee7fd7148c9b0fb40e91640057dfe42238faf094 (diff)
add preamble support
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--js/Renderer.ts13
-rw-r--r--package-lock.json24
-rw-r--r--package.json1
-rw-r--r--webpack.config.js3
4 files changed, 30 insertions, 11 deletions
diff --git a/js/Renderer.ts b/js/Renderer.ts
index 1f77c98..60bab9c 100644
--- a/js/Renderer.ts
+++ b/js/Renderer.ts
@@ -5,6 +5,7 @@ import * as AnchorPlugin from 'markdown-it-anchor';
import * as slugify from 'slugify';
import * as TOCPlugin from 'markdown-it-table-of-contents';
import VideoPlugin from './VideoPlugin';
+import * as PreamblePlugin from 'markdown-it-github-preamble';
import 'katex/dist/katex.min.css';
import 'highlight.js/styles/github.css';
@@ -84,6 +85,7 @@ export class Renderer {
this.md.use(TOCPlugin, {
slugify: slugifyHeading
});
+ this.md.use(PreamblePlugin);
this.md.use(VideoPlugin);
this.md.use(iterator, 'url_new_win', 'link_open', (tokens: MarkdownIt.Token[], idx: number) => {
const href = tokens[idx].attrGet('href') as string;
@@ -112,15 +114,6 @@ export class Renderer {
injectLineNumbers;
}
- prepareText(text: string): string {
- if (text.substr(0, 3) === '+++') {
- text = text.substr(3);
- text = text.substr(text.indexOf('+++') + 3);
- }
-
- return text;
- }
-
getLinkUrl(path: string): string {
if (path[0] === '#') {
return '#' + slugifyHeading(path.substr(1));
@@ -148,7 +141,7 @@ export class Renderer {
renderText(text: string, element): Thenable<void> {
return this.loadPlugins(text).then(() => {
- const html = this.md.render(this.prepareText(text));
+ const html = this.md.render(text);
element.html(html);
}
);
diff --git a/package-lock.json b/package-lock.json
index eb226a7..599d0c5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2802,6 +2802,30 @@
"resolved": "https://registry.npmjs.org/markdown-it-for-inline/-/markdown-it-for-inline-0.1.1.tgz",
"integrity": "sha1-Q18jFvW15o4UUM+iJC8rjVmtx18="
},
+ "markdown-it-github-preamble": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/markdown-it-github-preamble/-/markdown-it-github-preamble-1.0.0.tgz",
+ "integrity": "sha1-C8JbaKsrUyeFTOMUneKZDeaGrYY=",
+ "requires": {
+ "js-yaml": "3.9.1"
+ },
+ "dependencies": {
+ "esprima": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
+ "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
+ },
+ "js-yaml": {
+ "version": "3.9.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.9.1.tgz",
+ "integrity": "sha512-CbcG379L1e+mWBnLvHWWeLs8GyV/EMw862uLI3c+GxVyDHWZcjZinwuBd3iW2pgxgIlksW/1vNJa4to+RvDOww==",
+ "requires": {
+ "argparse": "1.0.9",
+ "esprima": "4.0.0"
+ }
+ }
+ }
+ },
"markdown-it-highlightjs": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/markdown-it-highlightjs/-/markdown-it-highlightjs-3.0.0.tgz",
diff --git a/package.json b/package.json
index 1de2dc4..dc16cae 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"markdown-it": "^8.4.0",
"markdown-it-anchor": "^4.0.0",
"markdown-it-for-inline": "^0.1.1",
+ "markdown-it-github-preamble": "^1.0.0",
"markdown-it-highlightjs": "^3.0.0",
"markdown-it-table-of-contents": "^0.3.2",
"markdown-it-texmath": "^0.4.3",
diff --git a/webpack.config.js b/webpack.config.js
index 1d627bc..f341b2a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -35,7 +35,8 @@ module.exports = {
path.resolve(__dirname, "js"),
path.resolve(__dirname, "node_modules/markdown-it-anchor"),
path.resolve(__dirname, "node_modules/markdown-it-texmath"),
- path.resolve(__dirname, "node_modules/markdown-it-highlightjs")
+ path.resolve(__dirname, "node_modules/markdown-it-highlightjs"),
+ path.resolve(__dirname, "node_modules/markdown-it-github-preamble")
],
use: {
loader: 'babel-loader'