From 7ea5a6a221e457f34fc2e6d1908cbf691b1de435 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sat, 20 Jun 2020 12:52:03 +0200 Subject: [PATCH 1/3] added plugins added the plugins: - markdown-it-mark - markdown-it-ins - markdown-it-sub - markdown-it-sup --- package.json | 4 ++++ yarn.lock | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/package.json b/package.json index ecb1e7571..9f1db34b4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,11 @@ "i18next-http-backend": "1.0.15", "markdown-it": "11.0.0", "markdown-it-emoji": "1.4.0", + "markdown-it-ins": "^3.0.0", + "markdown-it-mark": "^3.0.0", "markdown-it-regex": "0.2.0", + "markdown-it-sub": "^1.0.0", + "markdown-it-sup": "^1.0.0", "markdown-it-task-lists": "2.1.1", "moment": "2.27.0", "node-sass": "4.14.1", diff --git a/yarn.lock b/yarn.lock index 47898bda0..fa84fd697 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7275,11 +7275,31 @@ markdown-it-emoji@1.4.0: resolved "https://registry.yarnpkg.com/markdown-it-emoji/-/markdown-it-emoji-1.4.0.tgz#9bee0e9a990a963ba96df6980c4fddb05dfb4dcc" integrity sha1-m+4OmpkKljupbfaYDE/dsF37Tcw= +markdown-it-ins@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/markdown-it-ins/-/markdown-it-ins-3.0.0.tgz#b1b56824c78dc66e52b0fc97531b317cd78d79d2" + integrity sha512-+vyAdBuMGwmT2yMlAFJSx2VR/0QZ1onQ/Mkkmr4l9tDFOh5sVoAgRbkgbuSsk+sxJ9vaMH/IQ323ydfvQrPO/Q== + +markdown-it-mark@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/markdown-it-mark/-/markdown-it-mark-3.0.0.tgz#27c3e39ef3cc310b2dde5375082c9fa912983cda" + integrity sha512-HqMWeKfMMOu4zBO0emmxsoMWmbf2cPKZY1wP6FsTbKmicFfp5y4L3KXAsNeO1rM6NTJVOrNlLKMPjWzriBGspw== + markdown-it-regex@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/markdown-it-regex/-/markdown-it-regex-0.2.0.tgz#e09ad2d75209720d591d3949e1142c75c0fbecf6" integrity sha512-111UnMGJSt37gy+DlgcpQNwEfS2jvscOFSztzGhuXUHk7K1J5eAEj6C3jifmKb0cWtTuxdpHgIt4PyGQ+DtDjw== +markdown-it-sub@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/markdown-it-sub/-/markdown-it-sub-1.0.0.tgz#375fd6026eae7ddcb012497f6411195ea1e3afe8" + integrity sha1-N1/WAm6ufdywEkl/ZBEZXqHjr+g= + +markdown-it-sup@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz#cb9c9ff91a5255ac08f3fd3d63286e15df0a1fc3" + integrity sha1-y5yf+RpSVawI8/09YyhuFd8KH8M= + markdown-it-task-lists@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/markdown-it-task-lists/-/markdown-it-task-lists-2.1.1.tgz#f68f4d2ac2bad5a2c373ba93081a1a6848417088" From 7166de10f3b68c779641c5c8062c440f988eb4ff Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sat, 20 Jun 2020 12:52:38 +0200 Subject: [PATCH 2/3] added typescript definitions added typescript definitions for the plugins: - markdown-it-mark - markdown-it-ins - markdown-it-sub - markdown-it-sup --- src/external-types/markdown-it-ins/index.d.ts | 6 ++++++ src/external-types/markdown-it-mark/index.d.ts | 6 ++++++ src/external-types/markdown-it-sub/index.d.ts | 6 ++++++ src/external-types/markdown-it-sup/index.d.ts | 6 ++++++ 4 files changed, 24 insertions(+) create mode 100644 src/external-types/markdown-it-ins/index.d.ts create mode 100644 src/external-types/markdown-it-mark/index.d.ts create mode 100644 src/external-types/markdown-it-sub/index.d.ts create mode 100644 src/external-types/markdown-it-sup/index.d.ts diff --git a/src/external-types/markdown-it-ins/index.d.ts b/src/external-types/markdown-it-ins/index.d.ts new file mode 100644 index 000000000..ee134cf6d --- /dev/null +++ b/src/external-types/markdown-it-ins/index.d.ts @@ -0,0 +1,6 @@ + +declare module 'markdown-it-ins' { + import MarkdownIt from 'markdown-it/lib' + const markdownItInserted: MarkdownIt.PluginSimple + export = markdownItInserted +} diff --git a/src/external-types/markdown-it-mark/index.d.ts b/src/external-types/markdown-it-mark/index.d.ts new file mode 100644 index 000000000..13cdceb0d --- /dev/null +++ b/src/external-types/markdown-it-mark/index.d.ts @@ -0,0 +1,6 @@ + +declare module 'markdown-it-mark' { + import MarkdownIt from 'markdown-it/lib' + const markdownItMark: MarkdownIt.PluginSimple + export = markdownItMark +} diff --git a/src/external-types/markdown-it-sub/index.d.ts b/src/external-types/markdown-it-sub/index.d.ts new file mode 100644 index 000000000..b5af9f5d4 --- /dev/null +++ b/src/external-types/markdown-it-sub/index.d.ts @@ -0,0 +1,6 @@ + +declare module 'markdown-it-sub' { + import MarkdownIt from 'markdown-it/lib' + const markdownItSubscript: MarkdownIt.PluginSimple + export = markdownItSubscript +} diff --git a/src/external-types/markdown-it-sup/index.d.ts b/src/external-types/markdown-it-sup/index.d.ts new file mode 100644 index 000000000..85eb51ace --- /dev/null +++ b/src/external-types/markdown-it-sup/index.d.ts @@ -0,0 +1,6 @@ + +declare module 'markdown-it-sup' { + import MarkdownIt from 'markdown-it/lib' + const markdownItSuperscript: MarkdownIt.PluginSimple + export = markdownItSuperscript +} From 28e761e9c697d8fe4d5a5d3ba34b420ca62897b5 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sat, 20 Jun 2020 12:53:45 +0200 Subject: [PATCH 3/3] used new plugins in markdown-preview this re adds support for sub- and superscript and inserted and marked text closes #216 --- .../editor/markdown-preview/markdown-preview.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/editor/markdown-preview/markdown-preview.tsx b/src/components/editor/markdown-preview/markdown-preview.tsx index a60349fcd..1b6cb73d6 100644 --- a/src/components/editor/markdown-preview/markdown-preview.tsx +++ b/src/components/editor/markdown-preview/markdown-preview.tsx @@ -2,6 +2,10 @@ import MarkdownIt from 'markdown-it' import emoji from 'markdown-it-emoji' import markdownItRegex from 'markdown-it-regex' import taskList from 'markdown-it-task-lists' +import subscript from 'markdown-it-sub' +import superscript from 'markdown-it-sup' +import inserted from 'markdown-it-ins' +import marked from 'markdown-it-mark' import React, { ReactElement, useMemo } from 'react' import ReactHtmlParser, { convertNodeToElement, Transform } from 'react-html-parser' import { MarkdownItParserDebugger } from './markdown-it-plugins/parser-debugger' @@ -33,6 +37,10 @@ const MarkdownPreview: React.FC = ({ content }) => { }) md.use(taskList) md.use(emoji) + md.use(subscript) + md.use(superscript) + md.use(inserted) + md.use(marked) md.use(markdownItRegex, replaceLegacyYoutubeShortCode) md.use(markdownItRegex, replaceLegacyVimeoShortCode) md.use(markdownItRegex, replaceLegacyGistShortCode)