admin管理员组

文章数量:1123153

In details section, for example -

<details>
  <summary>Some title</summary>
  Some text with [link](url)
</details>

the text [link](url) won't convert to an URL, it stays unparsed. The same text outside details works fine.

Is it some markdown restriction ? How to put links to details then ?

In details section, for example -

<details>
  <summary>Some title</summary>
  Some text with [link](url)
</details>

the text [link](url) won't convert to an URL, it stays unparsed. The same text outside details works fine.

Is it some markdown restriction ? How to put links to details then ?

Share Improve this question asked 5 hours ago Юрий ГерасимовЮрий Герасимов 1 New contributor Юрий Герасимов is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

Markdown handling of this scenario varies widely by implementation. But Docusaurus uses CommonMark for markdown.

CommonMark in turn has extensive documentation on their handling of HTML blocks which is what you're using to embed HTML directly into the Markdown file.

Boiling that all down, you can solve this in two distinct ways, shown below.

Use two html blocks with markdown in between

CommonMark (somewhat surprisingly) allows unbalanced HTML blocks. So you can use a block to start your HTML, some markdown in the middle, and a block to end it. HTML blocks are separated from Markdown blocks by a single blank line, like this:

<details>
  <summary>Some title</summary>

  Some text with [link](url)

</details>

Note: This will create a paragraph <p> around your text which may not be what you want depending on your situation.

Use HTML

If you want tighter control over the produced HTML you can just do the link in the HTML directly.

<details>
  <summary>Some title</summary>
  Some text with <a href="url">link</a>
</details>

本文标签: In Docusaurus markdown link inside details won39t parseStack Overflow