@@ -5,11 +5,13 @@ import unified from "unified";
55import markdown from "remark-parse" ;
66import rehype from "remark-rehype" ;
77import stringify from "rehype-stringify" ;
8+ import vFile from "vfile" ;
89
910import { highight_code_block } from "./highlight" ;
1011import { split_view } from "./split_view" ;
1112
1213import u from "unist-builder" ;
14+ import { custom_vfile } from "./types" ;
1315
1416const { process } = unified ( )
1517 . use ( markdown )
@@ -48,7 +50,9 @@ console.log('boo')
4850\`\`\`
4951` ;
5052
51- const output = await process ( src ) ;
53+ const output = await process (
54+ vFile < custom_vfile > ( { contents : src , data : { docs_type : "docs" } } )
55+ ) ;
5256
5357 assert . equal (
5458 output . contents ,
@@ -60,7 +64,7 @@ console.log('boo')
6064 ) ;
6165} ) ;
6266
63- split ( "wraps from hr to end of code block in split view markup " , async ( ) => {
67+ split ( "works with other content present " , async ( ) => {
6468 const src = `
6569### hello
6670
@@ -77,8 +81,9 @@ console.log('boo')
7781## hello
7882` ;
7983
80- const output = await process ( src ) ;
81-
84+ const output = await process (
85+ vFile < custom_vfile > ( { contents : src , data : { docs_type : "docs" } } )
86+ ) ;
8287 assert . equal (
8388 output . contents ,
8489 "<h3>hello</h3>\n" +
@@ -89,4 +94,37 @@ console.log('boo')
8994 "<h2>hello</h2>"
9095 ) ;
9196} ) ;
97+
98+ split ( "ignore non-docs content" , async ( ) => {
99+ const src = `
100+ ### hello
101+
102+ ___
103+
104+ this is more text
105+
106+ and this
107+
108+ \`\`\`js
109+ console.log('boo')
110+ \`\`\`
111+
112+ ## hello
113+ ` ;
114+
115+ const output = await process (
116+ vFile < custom_vfile > ( { contents : src , data : { docs_type : "blof" } } )
117+ ) ;
118+ assert . equal (
119+ output . contents ,
120+
121+ "<h3>hello</h3>\n" +
122+ "<hr>\n" +
123+ "<p>this is more text</p>\n" +
124+ "<p>and this</p>\n" +
125+ `<pre class='language-javascript'><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'boo'</span><span class="token punctuation">)</span></code></pre>\n` +
126+ "<h2>hello</h2>"
127+ ) ;
128+ } ) ;
129+
92130split . run ( ) ;
0 commit comments