mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 15:44:45 -04:00

* Add basic markdown it rendering * Add markdown preview * Add embedings for vimeo, youtube, gist * Add support for legacy shortcodes and link detection * Set "both" as editor default * Add markdown-it-task-lists * Add twemoji * Changed SlideShare short-code behaviour from embedding to generating a link * Extract markdown it parser debugger into separate component * Deactivate markdown it linkify for now * Add link safety attributes * Add one-click-embedding component and use it * Added embedding changes and deprecations to CHANGELOG.md Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Philip Molares <philip@mauricedoepke.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
18 lines
723 B
TypeScript
18 lines
723 B
TypeScript
import { RegexOptions } from '../../../../external-types/markdown-it-regex/interface'
|
|
|
|
const protocolRegex = /(?:http(?:s)?:\/\/)?/
|
|
const domainRegex = /(?:gist\.github\.com\/)/
|
|
const idRegex = /(\w+\/\w+)/
|
|
const tailRegex = /(?:[./?#].*)?/
|
|
const gistUrlRegex = new RegExp(`(?:${protocolRegex.source}${domainRegex.source}${idRegex.source}${tailRegex.source})`)
|
|
const linkRegex = new RegExp(`^${gistUrlRegex.source}$`, 'i')
|
|
|
|
export const replaceGistLink: RegexOptions = {
|
|
name: 'gist-link',
|
|
regex: linkRegex,
|
|
replace: (match) => {
|
|
// ESLint wants to collapse this tag, but then the tag won't be valid html anymore.
|
|
// noinspection CheckTagEmptyBody
|
|
return `<codimd-gist id="${match}"></codimd-gist>`
|
|
}
|
|
}
|