PaloAltoNetworks / docusaurus-openapi-docs

🦝 OpenAPI plugin for generating API reference docs in Docusaurus v3.
https://docusaurus-openapi.tryingpan.dev
MIT License
642 stars 220 forks source link

Fenced code blocks started with `~~~` are incorrectly cleaned in v3 #883

Open Ugzuzg opened 2 months ago

Ugzuzg commented 2 months ago

Describe the bug

Markdown supports initiating fenced code blocks with ~~~, https://www.markdownguide.org/extended-syntax/#fenced-code-blocks, but it is incorrectly cleaned.

Expected behavior

~~~
{
}
~~~

Current behavior

~~~
\{
\}
~~~

Possible solution

Modify the cleaning regexp: https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts#L65

Steps to reproduce

  1. Add a code block using ~~~ to the description of a field in OpenAPI specification containing a JSON object.
  2. Generate markdown from OpenAPI specification with docusaurus gen-api-docs all.
  3. See curly braces prefixed with the backslash in the generated files.

Screenshots

Code block initiated with ~~~: Image

Code block initiated with ``` works as expected: Image

Context

Your Environment

sserrata commented 2 months ago

Hi @Ugzuzg, thanks for reporting the issue. The fix seems straightforward but can you provide steps to reproduce so I can be certain I'm addressing your issue? Are you defining these code blocks/fences in normal doc files or embedding them inside your OpenAPI spec summary/description?

Ugzuzg commented 1 month ago

@sserrata, edited the description with more details.