diff --git a/src/DocsParser.ts b/src/DocsParser.ts index 1e49bad..3f1fdaa 100644 --- a/src/DocsParser.ts +++ b/src/DocsParser.ts @@ -157,7 +157,7 @@ export class DocsParser { | ElementDocumentationContainer )[] = []; const contents = await fs.readFile(filePath, 'utf8'); - const md = new MarkdownIt(); + const md = new MarkdownIt({ html: true }); const allTokens = md.parse(contents, {}); @@ -263,7 +263,7 @@ export class DocsParser { private async parseStructure(filePath: string): Promise { const contents = await fs.readFile(filePath, 'utf8'); - const md = new MarkdownIt(); + const md = new MarkdownIt({ html: true }); const tokens = md.parse(contents, {}); const baseInfos = await this.parseBaseContainers(filePath, contents, tokens); diff --git a/src/__tests__/__snapshots__/markdown-helpers.spec.ts.snap b/src/__tests__/__snapshots__/markdown-helpers.spec.ts.snap index cfdeb52..d6cc82b 100644 --- a/src/__tests__/__snapshots__/markdown-helpers.spec.ts.snap +++ b/src/__tests__/__snapshots__/markdown-helpers.spec.ts.snap @@ -341,6 +341,17 @@ exports[`markdown-helpers safelyJoinTokens snapshots should be correct for parag Hey" `; +exports[`markdown-helpers safelyJoinTokens snapshots should be correct for paragraph-with-br-tag 1`] = ` +"Process: Main + _This class is not exported from the \`'electron'\` module. It is only available as a return value of other methods in the Electron API._ + +Process: Main + _This class is not exported from the \`'electron'\` module. It is only available as a return value of other methods in the Electron API._ + +Process: Main + _This class is not exported from the \`'electron'\` module. It is only available as a return value of other methods in the Electron API._" +`; + exports[`markdown-helpers safelyJoinTokens snapshots should be correct for paragraph-with-inline-code 1`] = `"This is a \`inline code\` block that is \`code\` tagged."`; exports[`markdown-helpers safelyJoinTokens snapshots should be correct for paragraph-with-links 1`] = `"This paragraph has a bunch of stuff. Also some links Foo, these links should be stripped."`; diff --git a/src/__tests__/block-parsers.spec.ts b/src/__tests__/block-parsers.spec.ts index 0972be2..56ba23e 100644 --- a/src/__tests__/block-parsers.spec.ts +++ b/src/__tests__/block-parsers.spec.ts @@ -3,7 +3,7 @@ import { parseMethodBlocks } from '../block-parsers'; describe('block parsers', () => { it('should parse a method', async () => { - const md = new MarkdownIt(); + const md = new MarkdownIt({ html: true }); const contents = ` # \`test.foo(x)\` * \`x\` Integer - x diff --git a/src/__tests__/fixtures/paragraph-with-br-tag.md b/src/__tests__/fixtures/paragraph-with-br-tag.md new file mode 100644 index 0000000..cd83b0f --- /dev/null +++ b/src/__tests__/fixtures/paragraph-with-br-tag.md @@ -0,0 +1,8 @@ +Process: [Main](../glossary.md#main-process)
+_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._ + +Process: [Main](../glossary.md#main-process)
+_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._ + +Process: [Main](../glossary.md#main-process)
+_This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._ diff --git a/src/__tests__/markdown-helpers.spec.ts b/src/__tests__/markdown-helpers.spec.ts index 2aaa552..899d769 100644 --- a/src/__tests__/markdown-helpers.spec.ts +++ b/src/__tests__/markdown-helpers.spec.ts @@ -18,7 +18,7 @@ import { import { DocumentationTag } from '../ParsedDocumentation'; const getTokens = (md: string) => { - const markdown = new MarkdownIt(); + const markdown = new MarkdownIt({ html: true }); return markdown.parse(md, {}); }; diff --git a/src/markdown-helpers.ts b/src/markdown-helpers.ts index d23f693..c9cf18a 100644 --- a/src/markdown-helpers.ts +++ b/src/markdown-helpers.ts @@ -578,6 +578,8 @@ export const safelyJoinTokens = (tokens: Token[], options: JoinTokenOptions = {} 's_close', 'blockquote_open', 'blockquote_close', + 'html_block', + 'html_inline', ], 'We only support plain text, links, softbreaks, inline code, strong tags and paragraphs inside joinable tokens', ); @@ -640,6 +642,13 @@ export const safelyJoinTokens = (tokens: Token[], options: JoinTokenOptions = {} break; case 'paragraph_open': case 'blockquote_close': + case 'html_block': + break; + case 'html_inline': + // Replace
elements with a newline + if (tokenToCheck.content.match(//)) { + joinedContent += '\n'; + } break; case 'fence': if (options.parseCodeFences) {