mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
Add a wrapper for linkify (#268)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
b74bb8e71d
commit
cdadc7b41a
3 changed files with 21 additions and 0 deletions
|
@ -0,0 +1,13 @@
|
|||
import MarkdownIt from 'markdown-it/lib'
|
||||
import linkify from 'markdown-it/lib/rules_core/linkify'
|
||||
|
||||
export const linkifyExtra: MarkdownIt.PluginSimple = (md) => {
|
||||
md.core.ruler.push('linkify', state => {
|
||||
try {
|
||||
state.md.options.linkify = true
|
||||
return linkify(state)
|
||||
} finally {
|
||||
state.md.options.linkify = false
|
||||
}
|
||||
})
|
||||
}
|
|
@ -20,6 +20,7 @@ import ReactHtmlParser, { convertNodeToElement, Transform } from 'react-html-par
|
|||
import MathJaxReact from 'react-mathjax'
|
||||
import { createRenderContainer, validAlertLevels } from './container-plugins/alert'
|
||||
import { highlightedCode } from './markdown-it-plugins/highlighted-code'
|
||||
import { linkifyExtra } from './markdown-it-plugins/linkify-extra'
|
||||
import { MarkdownItParserDebugger } from './markdown-it-plugins/parser-debugger'
|
||||
import './markdown-renderer.scss'
|
||||
import { replaceGistLink } from './regex-plugins/replace-gist-link'
|
||||
|
@ -97,6 +98,7 @@ const createMarkdownIt = ():MarkdownIt => {
|
|||
md.use(markdownItRegex, replaceQuoteExtraAuthor)
|
||||
md.use(markdownItRegex, replaceQuoteExtraColor)
|
||||
md.use(markdownItRegex, replaceQuoteExtraTime)
|
||||
md.use(linkifyExtra)
|
||||
md.use(MarkdownItParserDebugger)
|
||||
|
||||
validAlertLevels.forEach(level => {
|
||||
|
|
6
src/external-types/markdown-it-linkify/index.d.ts
vendored
Normal file
6
src/external-types/markdown-it-linkify/index.d.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
declare module 'markdown-it/lib/rules_core/linkify' {
|
||||
import { RuleCore } from 'markdown-it/lib/parser_core'
|
||||
const markdownItLinkify: RuleCore
|
||||
export = markdownItLinkify
|
||||
}
|
Loading…
Reference in a new issue