mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
17 lines
675 B
TypeScript
17 lines
675 B
TypeScript
import markdownItRegex from 'markdown-it-regex'
|
|
import MarkdownIt from 'markdown-it/lib'
|
|
import { RegexOptions } from '../../../external-types/markdown-it-regex/interface'
|
|
|
|
const finalRegex = /^{%slideshare (\w+\/[\w-]+) ?%}$/
|
|
|
|
export const legacySlideshareShortCode: MarkdownIt.PluginSimple = (markdownIt) => {
|
|
markdownItRegex(markdownIt, replaceLegacySlideshareShortCode)
|
|
}
|
|
|
|
export const replaceLegacySlideshareShortCode: RegexOptions = {
|
|
name: 'legacy-slideshare-short-code',
|
|
regex: finalRegex,
|
|
replace: (match) => {
|
|
return `<a target="_blank" rel="noopener noreferrer" href="https://www.slideshare.net/${match}">https://www.slideshare.net/${match}</a>`
|
|
}
|
|
}
|