vowel 0.3.0 → 0.3.2
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.
- package/package.json +2 -1
- package/plugins/markdown/index.js +31 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vowel",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"bin": "bin.js",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"postcss": "^8.5.9",
|
|
48
48
|
"rehype": "^13.0.2",
|
|
49
49
|
"rehype-document": "^7.0.3",
|
|
50
|
+
"rehype-github-alert": "^1.0.0",
|
|
50
51
|
"rehype-parse": "^9.0.1",
|
|
51
52
|
"rehype-preset-minify": "^7.0.1",
|
|
52
53
|
"rehype-slug": "^6.0.0",
|
|
@@ -13,6 +13,7 @@ import { gfmFootnoteFromMarkdown } from "mdast-util-gfm-footnote"
|
|
|
13
13
|
import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough'
|
|
14
14
|
import { gfmStrikethroughFromMarkdown } from 'mdast-util-gfm-strikethrough'
|
|
15
15
|
import { gfmTable } from 'micromark-extension-gfm-table'
|
|
16
|
+
import rehypeGithubAlert from "rehype-github-alert"
|
|
16
17
|
import { gfmTableFromMarkdown } from 'mdast-util-gfm-table'
|
|
17
18
|
import { h } from 'hastscript'
|
|
18
19
|
import { normalizeHeadings } from 'mdast-normalize-headings'
|
|
@@ -903,9 +904,8 @@ function writeHTML(destination, database, config) {
|
|
|
903
904
|
treeContent
|
|
904
905
|
])
|
|
905
906
|
|
|
906
|
-
/* URL handling */
|
|
907
907
|
visit(treeMain, (node, index, parent) => {
|
|
908
|
-
if (node.type === "text" && parent.tagName === 'p' && parent.children.length === 1) {
|
|
908
|
+
/* URLs */ if (node.type === "text" && parent.tagName === 'p' && parent.children.length === 1) {
|
|
909
909
|
const validURL = testURL(node.value)
|
|
910
910
|
if (validURL) {
|
|
911
911
|
const metadata = database.url.get(node.value)
|
|
@@ -918,6 +918,35 @@ function writeHTML(destination, database, config) {
|
|
|
918
918
|
]
|
|
919
919
|
}
|
|
920
920
|
}
|
|
921
|
+
} /* GFM Alerts */ else if (node.tagName === "blockquote") {
|
|
922
|
+
if (node.children[1]
|
|
923
|
+
&& node.children[1].tagName === "p"
|
|
924
|
+
&& node.children[1].children.length === 1
|
|
925
|
+
&& node.children[1].children[0].type === "text"
|
|
926
|
+
) {
|
|
927
|
+
const matches = node.children[1].children[0].value.match(/^\[!(\w+)\]$/)
|
|
928
|
+
|
|
929
|
+
if (matches) {
|
|
930
|
+
const [_, alertLabel] = matches
|
|
931
|
+
|
|
932
|
+
node.tagName = "aside"
|
|
933
|
+
node.properties = {
|
|
934
|
+
class: `alert ${alertLabel.toLowerCase()}`
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
node.children.splice(0, 2, {
|
|
938
|
+
type: "element",
|
|
939
|
+
tagName: "h2",
|
|
940
|
+
children: [
|
|
941
|
+
{
|
|
942
|
+
value: toTitleCase(alertLabel),
|
|
943
|
+
type: "text"
|
|
944
|
+
}
|
|
945
|
+
]
|
|
946
|
+
})
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
}
|
|
921
950
|
}
|
|
922
951
|
})
|
|
923
952
|
|
|
@@ -1027,7 +1056,6 @@ function writeHTML(destination, database, config) {
|
|
|
1027
1056
|
]
|
|
1028
1057
|
)
|
|
1029
1058
|
|
|
1030
|
-
|
|
1031
1059
|
const data = unified()
|
|
1032
1060
|
.use(rehypePresetMinify)
|
|
1033
1061
|
.use(rehypeStringify)
|