@@ -7,12 +7,12 @@ import normalize from "mdurl/encode";
7import merge from "deepmerge";
7import merge from "deepmerge";
8import github from "hast-util-sanitize/lib/github";
8import github from "hast-util-sanitize/lib/github";
9import remarkParse from "remark-parse";
9import remarkParse from "remark-parse";
10−import remarkRehype from "remark-rehype";
10+import remarkRehype, { defaultHandlers, all } from "remark-rehype";
11import rehypeStringify from "rehype-stringify";
11import rehypeStringify from "rehype-stringify";
12import rehypeRaw from "rehype-raw";
12import rehypeRaw from "rehype-raw";
14// img is wrapped in figure so that images can be extra wide in the blog posts
14// img is wrapped in figure so that images can be extra wide in the blog posts
15−function Img(h, node) {
15+function img(h, node) {
16 var props = { src: normalize(node.url), alt: node.alt };
16 var props = { src: normalize(node.url), alt: node.alt };
17 if (node.title !== null && node.title !== undefined) {
17 if (node.title !== null && node.title !== undefined) {
18 props.title = node.title;
18 props.title = node.title;
@@ -31,10 +31,43 @@ function Img(h, node) {
35+ const url = node.url;
38+ url.includes("https://urbit.org") ||
39+ url.startsWith("/") ||
48+ children: all(h, node),
59+ children: all(h, node),
64+const handlers = defaultHandlers;
34const options = {
68const options = {
35− handlers: {
69+ allowDangerousHtml: true,
36− image: Img,
70+ handlers: handlers,
38 sanitize: merge(github, {
71 sanitize: merge(github, {
39 // remove user-content from github.json to remark-slug work as expected
72 // remove user-content from github.json to remark-slug work as expected
40 clobberPrefix: "",
73 clobberPrefix: "",
@@ -45,14 +78,14 @@ const options = {
45// Converts markdown strings into markdown HTML/React components
78// Converts markdown strings into markdown HTML/React components
46export default async function Markdown({ post }, disablePlugins) {
79export default async function Markdown({ post }, disablePlugins) {
47 const result = await remark()
80 const result = await remark()
48− .use(remarkParse, options)
81+ .use(remarkParse)
49 .use(remarkprism, {
82 .use(remarkprism, {
50 plugins: !disablePlugins ? ["show-invisibles"] : [],
83 plugins: !disablePlugins ? ["show-invisibles"] : [],
53 .use(slug)
86 .use(slug)
54 .use(heading)
87 .use(heading)
55− .use(remarkRehype, { allowDangerousHtml: true })
88+ .use(remarkRehype, options)
56 .use(rehypeRaw)
89 .use(rehypeRaw)
57 .use(rehypeStringify)
90 .use(rehypeStringify)
58 .process(post.content);
91 .process(post.content);