Skip to content

Commit 5711524

Browse files
committed
Add support for flow content in markdown in JSDoc
1 parent 60aec01 commit 5711524

File tree

3 files changed

+73
-34
lines changed

3 files changed

+73
-34
lines changed

lib/render.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,15 @@ function createInfo(state, annotation) {
308308
removePosition(tree, {force: true})
309309

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

315322
list.children.push({

test/fixtures/errors/output.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
<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>
2424
<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>
2525
<ul>
26-
<li><strong>@param</strong> start The zero-based index number indicating the beginning of the substring.</li>
27-
<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.
26+
<li><strong>@param</strong>
27+
start The zero-based index number indicating the beginning of the substring.</li>
28+
<li><strong>@param</strong>
29+
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.
2830
If end is omitted, the characters from start through the end of the original string are returned.</li>
2931
</ul></div></div>
3032
<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>

0 commit comments

Comments
 (0)