Skip to content

Commit

Permalink
Add support for flow content in markdown in JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 4, 2024
1 parent 60aec01 commit 5711524
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 34 deletions.
11 changes: 9 additions & 2 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,15 @@ function createInfo(state, annotation) {
removePosition(tree, {force: true})

for (const [name, text] of tags) {
const value = '**@' + name + '**' + (text ? ' ' + text : '')
const fragment = fromMarkdown(value)
// Idea: support `{@link}` stuff.
//
// Use a `\n` here to join so that it’ll work when it is fenced code for
// example.
const value = '**@' + name + '**' + (text ? '\n' + text : '')
const fragment = fromMarkdown(value, {
extensions: [gfm()],
mdastExtensions: [gfmFromMarkdown()]
})
removePosition(fragment, {force: true})

list.children.push({
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/errors/output.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
<div class="rehype-twoslash-hover rehype-twoslash-popover" id="rehype-twoslash-e2lxOccc-2" popover=""><pre class="rehype-twoslash-popover-code"><code class="language-ts"><span class="pl-k">let</span> <span class="pl-smi">x</span><span class="pl-k">:</span> [<span class="pl-c1">string</span>, <span class="pl-c1">number</span>]</code></pre></div>
<div class="rehype-twoslash-hover rehype-twoslash-popover" id="rehype-twoslash-e2lxOccc-3" popover=""><pre class="rehype-twoslash-popover-code"><code class="language-ts">(<span class="pl-smi">method</span>) <span class="pl-c1">String</span>.<span class="pl-c1">substring</span>(<span class="pl-smi">start</span>: <span class="pl-smi">number</span>, <span class="pl-smi">end</span><span class="pl-k">?:</span> <span class="pl-smi">number</span>): <span class="pl-smi">string</span></code></pre><div class="rehype-twoslash-popover-description"><p>Returns the substring at the specified location within a String object.</p>
<ul>
<li><strong>@param</strong> start The zero-based index number indicating the beginning of the substring.</li>
<li><strong>@param</strong> end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end.
<li><strong>@param</strong>
start The zero-based index number indicating the beginning of the substring.</li>
<li><strong>@param</strong>
end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end.
If end is omitted, the characters from start through the end of the original string are returned.</li>
</ul></div></div>
<div class="rehype-twoslash-hover rehype-twoslash-popover" id="rehype-twoslash-e2lxOccc-4" popover=""><pre class="rehype-twoslash-popover-code"><code class="language-ts"><span class="pl-k">var</span> <span class="pl-smi">console</span><span class="pl-k">:</span> <span class="pl-en">Console</span></code></pre></div>
Expand Down
Loading

0 comments on commit 5711524

Please sign in to comment.