Bug: Widdershins generates unclosed <br> tags
shrirambalaji opened this issue · comments
Describe the bug
When descriptions have \n
character, widdershins generates a <br>
tag. This will not work when JSX is used, and is not applicable only to
but also to other HTML Void Elements, such as the ones mentioned here - https://github.com/jonschlinkert/self-closing-tags/blob/master/index.js.
A suggested fix would be to always convert \n
to <br />
instead of <br>
- - I have checked that my input document is valid OpenAPI 2.0/3.0.x or AsyncAPI 1.x
To Reproduce
Steps to reproduce the behavior:
- Command-line:
npx widdershins --search false --language_tabs 'ruby:Ruby' 'python:Python' --summary ./petstore-example.json -o petstore-example.md
- My input file: https://gist.github.com/Shriram-Balaji/a4a6dd4c2dbcce873f2b222497644e1f
- Scroll down to
description
inPet
. Find the\n
character
Expected behavior
Self Closing Tags, in rendered Markdown.
This sounds like a bug in react-dom. br
is a self closing tag. Do you have a link to any further discussion on that repo?
It's not specific to React-DOM, but JSX to be precise. JSX cannot parse self closing tags.
TLDR:
In JSX, the rules are a little different. Any JSX element can be written with a self-closing tag, and every element must be closed. The line-break tag, for example, must always be written as
in order to be valid JSX that can be transpiled.
@MikeRalphson Do you feel that this issue might be irrelevant? Atleast from what I've experienced, this minor problem makes using widdershins a little bit difficult for projects which transform markdown to JSX.
With the caveat that we're outputting markdown with some HTML, not targetting JSX ourselves, I can't see any downside to patching this. Thanks for raising the issue and for the PR.