@@ -2,6 +2,11 @@ import { readdir, readFile, writeFile, mkdir } from "fs/promises";
2
2
import * as path from "path" ;
3
3
import { ClassReflection } from "../types" ;
4
4
5
+ import { htmlToJsx } from "html-to-jsx-transform" ;
6
+ import convert from 'node-html-to-jsx' ;
7
+ import { NodeHtmlMarkdown , NodeHtmlMarkdownOptions } from 'node-html-markdown'
8
+
9
+
5
10
import { HtmlValidate } from "html-validate" ;
6
11
7
12
enum ClassMemberType {
@@ -202,9 +207,19 @@ function reshapeHTML(text) {
202
207
if ( Array . isArray ( text ) ) {
203
208
text = text . join ( " " ) ;
204
209
}
210
+ try {
211
+ const md = NodeHtmlMarkdown . translate ( text ) ;
212
+ return md ;
213
+ } catch ( ex ) {
214
+ console . error ( ex ) ;
215
+ }
216
+ return text ;
217
+ // return "```\n" + text + "\n```\n\n"
205
218
text = text . replaceAll ( / < [ ^ > ] * > / gi, "" ) ;
206
- text = text . replaceAll ( "{" , "{" ) ;
207
- text = text . replaceAll ( "}" , "}" ) ;
219
+ // text = text.replaceAll("{", "{");
220
+ // text = text.replaceAll(" }", "}");
221
+ // text = text.replaceAll("{", "\\{");
222
+ // text = text.replaceAll(" }", "\\ }");
208
223
// text = text.replaceAll(/({|}|\[|\])/g, "\\$1");
209
224
210
225
text = text . replaceAll ( / \< b r \s * \/ ? \> / gi, "<br />" ) ;
@@ -316,7 +331,7 @@ ${reshapeHTML(classDef.Class.description.join(" "))}
316
331
export async function generateDocFile ( classFile , folder , mdFile ) {
317
332
await mkdir ( folder , { recursive : true } ) ;
318
333
const mdFileFull = path . join ( folder , mdFile ) ;
319
- await writeFile ( mdFileFull , await generateDoc ( classFile , false ) ) ;
334
+ await writeFile ( mdFileFull , await generateDoc ( classFile , true ) ) ;
320
335
return mdFileFull ;
321
336
}
322
337
0 commit comments