All files / markdown / plugins / markers.ts

100.00% Branches 2/2
100.00% Lines 7/7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
 
x2
 
 
x116
 
 
 
 
 
 
 
 
 
 
 
 
 
x2
x2
 
x33
x4
x2






















// Imports
import type { Plugin } from "../renderer.ts"
import remarkFlexibleMarkers from "remark-flexible-markers"

/** Marker attributes */
const dictionary = Object.fromEntries([..."abcdefghijklmnopqrstuvwxyz"].map((letter) => [letter, letter]))

/**
 * Add support for markers.
 *
 * ```md
 * ==foo==
 * =r=bar=
 * ```
 * ```html
 * <p><mark>foo</mark></p>
 * <p><mark r>bar</mark></p>
 * ```
 */
export default {
  remark(processor) {
    // deno-lint-ignore no-explicit-any
    return processor.use(remarkFlexibleMarkers as any, { dictionary, markerClassName: () => [], markerProperties: (letter: string) => (letter ? { [letter]: true } : {}) } as any)
  },
} as Plugin