cloud-annotations / docusaurus-openapi

🦕 OpenAPI plugin for generating API reference docs in Docusaurus v2.
https://docusaurus-openapi.netlify.app
MIT License
498 stars 82 forks source link

MDX content in params is displayed in form elements #257

Closed chris48s closed 9 months ago

chris48s commented 1 year ago

Here's a screenshot showing the issue:

Screenshot at 2023-07-23 19-11-48

Ideally, the tags would be stripped in this context, leaving only the plain text.

I'd be happy to work on this issue. I'm not quite sure how to approach it though.

One option would be to just treat the placeholder as a string placeholder.replace(/(<([^>]+)>)/gi, ""); would be enough to remove HTML tags. Maybe markdown is the lesser evil. Crude but simple.

It seems like it should be possible to use some of the existing MDX/remark tooling that this lib and docusaurus already pull in to render the content of the string into a tree structure we can traverse and then extract just the text nodes. That seems like a more robust approach, but I'm not sure that MDX exposes a suitable API for that though.

bourdakos1 commented 1 year ago

It looks like marked has a text renderer so maybe we could try using that? https://github.com/markedjs/marked/blob/master/src/TextRenderer.js