From 4b3bc89e90b295ccff1e3ba36be17a76a571dc8b Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 30 Apr 2018 08:19:36 +0200 Subject: Add new plugins --- package.json | 11 +++++------ tohtml.js | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4bca5d1..54e29a4 100644 --- a/package.json +++ b/package.json @@ -18,17 +18,16 @@ "remark-custom-blocks": "^2.1.1", "remark-highlight.js": "^5.0.0", "remark-html": "^6.0.1", + "remark-iframes": "^3.0.1", "remark-kbd": "^1.0.6", - "remark-line-input": "git+http://git.ache.one/remark-line-input/", + "remark-line-input": "^0.3.0", + "remark-text-input": "^0.5.0", "remark-math": "^1.0.0", - "remark-mermaid-simple": "git+http://git.ache.one/remark-mermaid-simple/", - "remark-multiple-choice": "git+http://git.ache.one/remark-multiple-choice", + "remark-multiple-choice": "^0.1.0", "remark-parse": "^5.0.0", "remark-preset-lint-markdown-style-guide": "^2.1.1", "remark-rehype": "^3.0.0", - "remark-select": "git+http://git.ache.one/remark-select/", - "remark-special-box": "git+http://git.ache.one/remark-special-box/", - "remark-text-input": "git+http://git.ache.one/remark-text-input/", + "remark-select": "", "unified": "^6.1.6", "unist-util-inspect": "^4.1.2", "vfile-reporter": "^4.0.0" diff --git a/tohtml.js b/tohtml.js index 35173b4..4a5982d 100644 --- a/tohtml.js +++ b/tohtml.js @@ -19,6 +19,7 @@ const rehypeStringify = require('rehype-stringify'); const unified = require('unified'); const remark = require('remark-parse'); const customBlocks = require('remark-custom-blocks'); +const iframes = require('remark-iframes'); function toHTML(data, fnc) { unified() @@ -58,6 +59,26 @@ function toHTML(data, fnc) { classes: 'special-box bad', }}) .use(highlight) + .use(iframes, { + // this key corresponds to the hostname: !(http://hostname/foo) + // the config associated to this hostname will apply to any iframe + // with a matching hostname + 'www.youtube.com': { + tag: 'IFRAME', + width: 560, + height: 315, + disabled: false, + replace: [ + ['watch?v=', 'embed/'], + ['http://', 'https://'], + ], + thumbnail: { + format: 'http://img.youtube.com/vi/{id}/0.jpg', + id: '.+/(.+)$' + }, + removeAfter: '&' + } + }) .use(html, {allowDangerousHTML: true}) .use(rehypeKatex) .use(raw) -- cgit v1.2.3