-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
fix(v2): handle multiple asset links in one line properly #3653
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 51fa150 |
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.
Thanks, LGTM
@anshulrgoyal if there's a strong reason to modify the parent node it's time to tell us :)
}); | ||
|
||
parent.children.splice(index + 2, 0, {type: 'jsx', value: '</a>'}); | ||
} >${linkText}</a>`; |
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.
} >${linkText}</a>`; | |
}>${linkText}</a>`; |
Wonder if we can sately remove this space here? Seems not useful to keep it and unusual?
This would modify the snapshots but should be fine
I think it is to support children in a tag |
@anshulrgoyal can you give an example md snippet? not sure to understand what you mean by that but it may be worth adding an extra test case of this |
Something like this
|
oh, you mean an image link? |
In MDX the file is converted to MDAST->HAST->MDXAST. So we can't just put link text between |
Indeed, image links do not work in the current implementation (because that use case is not covered by unit test), as well as rendering other (child) HTML tags inside the asset link (because type for all children is hardcoded as In this PR I fixed these issues, see unit tests/snapshots for details. I also did a small cleanup code (removed extra spaces in the output and unnecessary Note for future refactoring: instead of using string interpolation we need to come up with a clearer and better way to create Strange (?) thing: It seems that the handling of asset paths between |
Hi @lex111 If a child is JSX then how is it handled like:-
|
Thanks @lex111 , LGTM! Tried this in MDX playground, didn't even know it was possible 🤪
Does your code support it currently? Looks like it support MD in link but JSX? Also what about adding a complex example of this dogfooding page?
Yes, this is a bit different, wanted to enable @site alias for both but didn't have time and had to release an urgent fix a few releases back 😅 if you can support @site alias in the other code as well that would be great :) |
JSX inside asset Markdown link is already supported, although I don't think anyone will use it actively, but I updated the test to make sure that it really works. |
Hmm, this is standard functionality that is assumed to work out of the box. I do not know which new use cases to add in the example demo page. So if you think you need to update this page, please feel free do it yourself. |
thanks, let's merge this :) |
Motivation
Attempt to fix #3631
Note: I didn't quite understand why the parent node content should be changed now, if it's easier and safer to change the child node (which was done).
Previous tests are passed successfully + add new test for new use case.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Unit tests (I guess).
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)