Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown templates not compatible with MDX v3 #223

Closed
coopernetes opened this issue Dec 10, 2023 · 1 comment · Fixed by #225
Closed

Markdown templates not compatible with MDX v3 #223

coopernetes opened this issue Dec 10, 2023 · 1 comment · Fixed by #225

Comments

@coopernetes
Copy link

coopernetes commented Dec 10, 2023

Hi,
I'm using this project to generate MDX files from our schema to feed into a Docusaurus static web site for documentation. It seems the md_nested template generates non-compliant Markdown with MDX due to mixing inline and newline styles.

Here's a snippet that's generated and where the mdx compiler gets upset:

<details>
<summary><strong> <a name="authorisedList"></a>1. [Optional] Property Git Proxy configuration file > authorisedList</strong>

</summary>
Error: MDX compilation failed for file "/home/tom/repos/git-proxy/website/docs/configuration/reference.mdx"
Cause: Expected a closing tag for `</strong>` (19:1-19:10) before the end of `paragraph`
Details:
{
  "column": 1,
  "message": "Expected a closing tag for `</strong>` (19:1-19:10) before the end of `paragraph`",
  "line": 19,
  "name": "19:1-19:125",
  "place": {
    "start": {
      "line": 19,
      "column": 1,
      "offset": 678,
      "_index": 0,
      "_bufferIndex": 0
    },
    "end": {
      "line": 19,
      "column": 125,
      "offset": 802,
      "_index": 1,
      "_bufferIndex": -1
    }
  },
  "reason": "Expected a closing tag for `</strong>` (19:1-19:10) before the end of `paragraph`",
  "ruleId": "end-tag-mismatch",
  "source": "mdast-util-mdx-jsx"
}

This isn't really a specific issue with JSFH. A new MDX compatible template could work to resolve this. For now, I'm doing a simple regex replace in my string to strip the leading two newlines in the md_nested template:

const schemaDoc = readFileSync(`${tempdir}${sep}schema.md`, 'utf-8')
    .replace(/\n\n<\/summary>/g, '</summary>'); // https://github.com/orgs/mdx-js/discussions/2260
const docString = `---
title: Schema Reference
description: JSON schema reference documentation for Git Proxy
---
  
${schemaDoc}
`;
@dblanchette
Copy link
Collaborator

I fixed the missing line feed after <summary>. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants