Skip to content
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

Language-specific Code Tabs (Code blocks) broke referenced links #1215

Closed
bruno-alencar opened this issue Jan 31, 2019 · 5 comments
Closed
Labels
difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.

Comments

@bruno-alencar
Copy link

🐛 Bug Report

Hi,

I'm using some referenced links and I've had a problem, to use the new feature Coding blocks.

Referenced markdown links:
markdown-links-issue

I've tried to use the Language-specific Code Tabs

markdown-code-issue

After that, my links have been broken.

markdown-broken

To Reproduce

  1. Add the example page on docusaurus docs

https://raw.githubusercontent.com/bruno-alencar/issue-docusaurus/master/test.md

  1. Remove comments (DOCUSAURUS_CODE_TABS, JavaScript, END_DOCUSAURUS_CODE_TABS)

and the link [Link][test-link] will work.

Expected behavior

If you put directly the link without reference.

expected

Actual Behavior

If you put link code after the comment block, the links broke.

error

Reproducible Demo

https://github.com/bruno-alencar/issue-docusaurus/blob/master/test.md

@bruno-alencar bruno-alencar changed the title Language-specific Code Tabs (Code blocks ) broke referenced links Language-specific Code Tabs (Code blocks) broke referenced links Feb 2, 2019
@cuddergambino
Copy link

I'm also getting the same issue.

Only way I've found to workaround (other than manually link all references) is to include the link reference before and after the code block.

Example:

[test-link]: https://github.com "Github page"

<!--DOCUSAURUS_CODE_TABS-->
<!--JavaScript-->
<!--END_DOCUSAURUS_CODE_TABS-->

[test-link]: https://github.com "Github page"

@blemelin
Copy link

blemelin commented Feb 25, 2019

Same here. I have multiple DOCUSAURUS_CODE_TABS sections on the same doc. When I remove the last one, everything is fine.

Tried on 1.6.2 and 1.7.2.

@yangshun yangshun added the difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. label Feb 25, 2019
@yangshun
Copy link
Contributor

yangshun commented Feb 25, 2019

Thank you all for the reports.

@fiennyangeln Do you have time to look into this?

@fiennyangeln
Copy link
Contributor

I will take a look at it tonight 😄

fiennyangeln added a commit to fiennyangeln/Docusaurus that referenced this issue Feb 26, 2019
- The reason is that the previous Codeblock implementation separates
the tabs, the markdown before tabs, and the markdown after tabs into
separate Remarkable component, thus they don't share information
regarding the reference link
- To solve this, change the Doc implementation so that one Doc
have only one Remarkable component by transforming the codeblock
into html string and add it as part of the markdown, letting the
Remarkable take care of the html string
- However, this approach made us need to ensure that there is no
newline in the codetab, otherwise, the formatting inside the
code will be broken. Thus, I replace every newline inside the
code tag with a br tag

Fix facebook#1215
@yangshun
Copy link
Contributor

@cuddergambino I think as long as the link is above the code tab it is ok, so the link below the code tab can be removed, as @blemelin mentioned.

yangshun pushed a commit that referenced this issue Feb 26, 2019
* Fix bug Code block tabs broke the referenced links

- The reason is that the previous Codeblock implementation separates
the tabs, the markdown before tabs, and the markdown after tabs into
separate Remarkable component, thus they don't share information
regarding the reference link
- To solve this, change the Doc implementation so that one Doc
have only one Remarkable component by transforming the codeblock
into html string and add it as part of the markdown, letting the
Remarkable take care of the html string
- However, this approach made us need to ensure that there is no
newline in the codetab, otherwise, the formatting inside the
code will be broken. Thus, I replace every newline inside the
code tag with a br tag

Fix #1215

* Fix prettier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan.
Projects
None yet
Development

No branches or pull requests

5 participants