mirror of
https://github.com/Luzifer/wiki.git
synced 2024-12-20 10:31:18 +00:00
Add automatic class bindings
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
2ef54b4218
commit
1eaec48b5a
1 changed files with 12 additions and 0 deletions
|
@ -6,6 +6,17 @@
|
||||||
<script>
|
<script>
|
||||||
import showdown from 'showdown'
|
import showdown from 'showdown'
|
||||||
|
|
||||||
|
const classMap = {
|
||||||
|
table: 'table',
|
||||||
|
}
|
||||||
|
|
||||||
|
const htmlClassBindings = Object.keys(classMap)
|
||||||
|
.map(key => ({
|
||||||
|
regex: new RegExp(`<${key}(.*)>`, 'g'),
|
||||||
|
replace: `<${key} class="${classMap[key]}" $1>`,
|
||||||
|
type: 'output',
|
||||||
|
}))
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -37,6 +48,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const converter = new showdown.Converter({
|
const converter = new showdown.Converter({
|
||||||
|
extensions: [...htmlClassBindings],
|
||||||
tables: true,
|
tables: true,
|
||||||
})
|
})
|
||||||
converter.setFlavor('github')
|
converter.setFlavor('github')
|
||||||
|
|
Loading…
Reference in a new issue