a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

make copied markdown lists tight always

+22 -8
+1
package-lock.json
··· 47 47 "swr": "^2.2.5", 48 48 "thumbhash": "^0.1.1", 49 49 "unified": "^11.0.5", 50 + "unist-util-visit": "^5.0.0", 50 51 "uuid": "^10.0.0", 51 52 "y-prosemirror": "^1.2.5", 52 53 "yjs": "^13.6.15",
+1
package.json
··· 49 49 "swr": "^2.2.5", 50 50 "thumbhash": "^0.1.1", 51 51 "unified": "^11.0.5", 52 + "unist-util-visit": "^5.0.0", 52 53 "uuid": "^10.0.0", 53 54 "y-prosemirror": "^1.2.5", 54 55 "yjs": "^13.6.15",
+20 -8
src/htmlMarkdownParsers.ts
··· 3 3 import remarkRehype from "remark-rehype"; 4 4 import rehypeStringify from "rehype-stringify"; 5 5 6 + import { visit } from "unist-util-visit"; 6 7 import rehypeParse from "rehype-parse"; 7 8 import rehypeRemark from "rehype-remark"; 8 9 import remarkStringify from "remark-stringify"; 10 + 11 + function remarkTightListify() { 12 + return (tree: any) => { 13 + visit(tree, "list", (node) => { 14 + node.spread = false; 15 + for (const child of node.children) { 16 + if (child.type === "listItem") { 17 + child.spread = false; 18 + } 19 + } 20 + }); 21 + }; 22 + } 9 23 10 24 export function markdownToHtml(markdown: string): string { 11 25 return String( ··· 13 27 .use(remarkParse) // Parse markdown content to a syntax tree 14 28 .use(remarkRehype) // Turn markdown syntax tree to HTML syntax tree, ignoring embedded HTML 15 29 .use(rehypeStringify) // Serialize HTML syntax tree 16 - .processSync(markdown) 30 + .processSync(markdown), 17 31 ); 18 32 } 19 33 ··· 22 36 unified() 23 37 .use(rehypeParse) // Parse HTML to a syntax tree 24 38 .use(rehypeRemark) // Turn HTML syntax tree to markdown syntax tree 25 - .use( 26 - remarkStringify, // Serialize HTML syntax tree 27 - { 28 - bullet: "-", // change default list marker from '*' 29 - } 30 - ) 31 - .processSync(html) 39 + .use(remarkTightListify) 40 + .use(remarkStringify, { 41 + bullet: "-", // change default list marker from '*' 42 + }) // Serialize HTML syntax tree 43 + .processSync(html), 32 44 ); 33 45 }