@globalbrain/sefirot 4.26.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { type Component, computed } from 'vue'
|
|
3
|
-
import { useMarkdown } from '../composables/Markdown'
|
|
3
|
+
import { type UseMarkdownOptions, useMarkdown } from '../composables/Markdown'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export interface SMarkdownProps extends UseMarkdownOptions {
|
|
6
6
|
tag?: Component | string
|
|
7
7
|
content: string
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<SMarkdownProps>(), {
|
|
11
11
|
tag: 'div',
|
|
12
12
|
html: true
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
const markdown = useMarkdown(
|
|
15
|
+
const markdown = useMarkdown(props)
|
|
16
16
|
const rendered = computed(() => markdown(props.content))
|
|
17
17
|
</script>
|
|
18
18
|
|
|
@@ -1,8 +1,71 @@
|
|
|
1
1
|
import DOMPurify, { type Config } from 'dompurify'
|
|
2
|
-
import MarkdownIt
|
|
2
|
+
import MarkdownIt from 'markdown-it'
|
|
3
3
|
|
|
4
4
|
export type UseMarkdown = (source: string, inline?: boolean) => string
|
|
5
5
|
|
|
6
|
+
// vendored for vue compatibility
|
|
7
|
+
export interface MarkdownItOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Set `true` to enable HTML tags in source. Be careful!
|
|
10
|
+
* That's not safe! You may need external sanitizer to protect output from XSS.
|
|
11
|
+
* It's better to extend features via plugins, instead of enabling HTML.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
html?: boolean | undefined
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Set `true` to add '/' when closing single tags
|
|
18
|
+
* (`<br />`). This is needed only for full CommonMark compatibility. In real
|
|
19
|
+
* world you will need HTML output.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
xhtmlOut?: boolean | undefined
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Set `true` to convert `\n` in paragraphs into `<br>`.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
breaks?: boolean | undefined
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* CSS language class prefix for fenced blocks.
|
|
32
|
+
* Can be useful for external highlighters.
|
|
33
|
+
* @default 'language-'
|
|
34
|
+
*/
|
|
35
|
+
langPrefix?: string | undefined
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set `true` to autoconvert URL-like text to links.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
linkify?: boolean | undefined
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Set `true` to enable [some language-neutral replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
|
|
45
|
+
* quotes beautification (smartquotes).
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
typographer?: boolean | undefined
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Double + single quotes replacement
|
|
52
|
+
* pairs, when typographer enabled and smartquotes on. For example, you can
|
|
53
|
+
* use `'«»„“'` for Russian, `'„“‚‘'` for German, and
|
|
54
|
+
* `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
|
|
55
|
+
* @default '“”‘’'
|
|
56
|
+
*/
|
|
57
|
+
quotes?: string | string[]
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Highlighter function for fenced code blocks.
|
|
61
|
+
* Highlighter `function (str, lang, attrs)` should return escaped HTML. It can
|
|
62
|
+
* also return empty string if the source was not changed and should be escaped
|
|
63
|
+
* externally. If result starts with <pre... internal wrapper is skipped.
|
|
64
|
+
* @default null
|
|
65
|
+
*/
|
|
66
|
+
highlight?: ((str: string, lang: string, attrs: string) => string) | null | undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
6
69
|
export interface UseMarkdownOptions extends MarkdownItOptions {
|
|
7
70
|
config?: (md: MarkdownIt) => void
|
|
8
71
|
/** @default false */
|
|
@@ -40,6 +103,16 @@ export function useMarkdown({
|
|
|
40
103
|
//
|
|
41
104
|
|
|
42
105
|
const md = new MarkdownIt({ html: true, linkify: true, ...options })
|
|
106
|
+
|
|
107
|
+
md.renderer.rules.ordered_list_open = (tokens, idx, options, env, self) => {
|
|
108
|
+
const token = tokens[idx]
|
|
109
|
+
const start = Number(token.attrGet('start')) - 1
|
|
110
|
+
if (start >= 0) {
|
|
111
|
+
token.attrSet('style', `counter-reset: s-medium-counter ${start}`)
|
|
112
|
+
}
|
|
113
|
+
return self.renderToken(tokens, idx, options)
|
|
114
|
+
}
|
|
115
|
+
|
|
43
116
|
config?.(md)
|
|
44
117
|
|
|
45
118
|
return (source, inline = _inline) => {
|
package/package.json
CHANGED