-
Notifications
You must be signed in to change notification settings - Fork 239
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
Strip markdown from parameter placeholder #1002
Comments
Hi @pmarschik, this is likely related to #1012. Basically, we need to decide whether we want to re-introduce remark rendering of descriptions/summaries or if Docusaurus could possibly provide a hook or method for rendering Docusaurus-style MDX client-side. |
Yes, except for the detail that #1012 is about 4.2 and I tested this with 4.1. I'd love for docusaurus to expose their MDX parsing facility client-side so the same markdown could be used. I know that the OAS spec just specifies CommonMark but having the same abilities as Docusaurus would be awesome. I've just had a cursory look at the docusaurus code and all of their parsing seems to be in the @docusaurus/mdx-loader package. However, not enough is exposed to clients to be able to use that. |
I'm not sure to understand the problem, but overall we don't really plan to ship an MDX parser/renderer to the client side 😅 |
So whats happening in this plugin:
But it would be awesome to get access to the configured MDX processor to render that raw markdown text. That way all configured remark/rehype plugins would work, as well as being able to use all configured mdx components. |
Thanks @pmarschik, I think that's the basic approach/idea - that the plugin could somehow use the custom remark plugins located here: https://github.com/facebook/docusaurus/tree/main/packages/docusaurus-mdx-loader/src/remark |
Unfortunately, it's unlikely to happen. Those remark plugins have various dependencies, some of them don't even work in a browser. Some plugins even use At best, we can expose a subset of the plugins, but it's impossible to expose all of them and expect things to work in a browser. The questions are:
Shipping |
Hi @pmarschik, now that #1016 is merged I was hoping you could help test the latest canary. Thanks! |
@sserrata I've tested with
|
Hi @pmarschik, I wasn't able to reproduce the admonition issue concerning the leading/trailing new lines. Can you share the full reproduction details in case I am missing something? As for the |
Alternatively, we could also first try to default to |
Directives are not std CommonMark, you probably need to use this syntax extension with strip-markdown: https://github.com/remarkjs/remark-directive Similarly, tables are a remark-gfm feature afaik: https://github.com/remarkjs/remark-gfm |
Yup, so the question is whether or not it's worth stripping all three, CommonMark, admonitions and GFM, in order to continue using descriptions as placeholders. For sure, I think the Also, since descriptions could be multiline and/or longer than can be displayed, it may also make sense to strip the first line and set a max character limit. Lastly, I was thinking we may also want to pass/support a |
Actually...let me qualify what I mean by "most useful option to display/use"... If the goal is to explain/teach then the If the goal is to provide a "ready to send" example payload for demonstrating the API than Maybe there's a way to support/display/use both, but I still feel like we would be duplicating at least some of the |
I might have missed a rebuild step in my testing, hence the issue with the leading/trailing lines. Anyways, I can work around that by updating the yaml files. Concerning what to display as a placeholder, I'll quote MDN:
So according to that definition |
Describe the bug
Have a
parameter
defined for some path.That parameter can have a
description
which according to the OAS spec supports CommonMark syntax.This
description
is used bypackages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx
(andParamArrayFormItem.tsx
) asplaceholder
on the<FormTextInput>
.This would show raw markdown if description contains markdown (e.g. a raw markdown link such as
leading [Some link](/pointing/somewhere) trailing
.Expected behavior
Strip the markdown to plaintext so the placeholder text is readable. The correctly rendered markdown is anyways in the main section.
So
leading [Some link](/pointing/somewhere) trailing
should becomeleading Some link trailing
.Current behavior
Raw markdown is rendered as text.
Possible solution
Maybe use something like https://github.com/remarkjs/strip-markdown to strip non markdown elements.
Your Environment
The text was updated successfully, but these errors were encountered: