Repository navigation
fix(Markdown): Escape open video tags #3442
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,18 @@ export const isCheckboxParent = (node: HTMLToReactNode, type: string) => | |
| node.children[0]?.attribs?.type === type | ||
| ); | ||
|
|
||
| // a <p> that only holds video tags, i.e. a single-line <video></video> that marked parsed as paragraph text | ||
| export const isVideoParent = (node: HTMLToReactNode, tagName: string) => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the name throws me off a little and the need to have name: parameter: doesn't hurt I guess, but given how specific the function name is, seems like it's always checking |
||
| Boolean( | ||
| node.name === 'p' && | ||
| node.children?.some((child) => child.name === tagName) && | ||
| node.children.every( | ||
| (child) => | ||
| child.name === tagName || | ||
| (child.type === 'text' && !child.data.trim()) | ||
| ) | ||
| ); | ||
|
|
||
| export const isLabelText = (node: HTMLToReactNode, type: string) => { | ||
| // we are using this text to create the accessible label, so are basically deduplicating it here | ||
| return Boolean( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,20 @@ | |
|
|
||
| ## Overview | ||
|
|
||
| ### Tests tests tests | ||
|
|
||
| In addition to images, HTML also supports displaying videos | ||
|
|
||
| Preview: Docs Embedding videos within a site creates lively and informative pages that are attractive to visitors. Like the `<img>` element, the `<video>` element requires a src attribute with a link to the video source. Unlike the `<img>` element however, the `<video>` element requires an opening and a closing tag. | ||
|
|
||
| <video> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this lead me down a rabbit hole of when someone might write raw HTML and markdown does not like that lol Seems like when using code fences (```) or inline backticks, the TL;DR: writing raw HTML in a markdown component is an edgecase, but probs not one worth worrying about |
||
|
|
||
| ):) | ||
|
|
||
| <video src="myVideo.mp4" width="320" height="240" controls> | ||
| Video not supported | ||
| </video> | ||
|
|
||
| ### Philosophy | ||
|
|
||
| Markdown is intended to be as easy-to-read and easy-to-write as is feasible. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also test code, yeah? i.e. to make testing easier?