Skip to content

Commit

Permalink
Merge 6c2841b into b1b8855
Browse files Browse the repository at this point in the history
  • Loading branch information
watagashi committed May 30, 2018
2 parents b1b8855 + 6c2841b commit a12433d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/__tests__/toc.js
Expand Up @@ -236,6 +236,7 @@ and next element in the same inline token`
mdIt(
`@[toc]
# [test](http://google.com)
## text [test](http://google.com)
## **text**
## *text*
## ~~text~~
Expand All @@ -245,6 +246,7 @@ and next element in the same inline token`
`<p><ul class="markdownIt-TOC">
<li><a href="#test">test</a>
<ul>
<li><a href="#text-test">text test</a></li>
<li><a href="#text"><strong>text</strong></a></li>
<li><a href="#text-2"><em>text</em></a></li>
<li><a href="#text-3"><s>text</s></a></li>
Expand All @@ -253,6 +255,7 @@ and next element in the same inline token`
</ul>
</p>
<h1 id="test"><a href="http://google.com">test</a></h1>
<h2 id="text-test">text <a href="http://google.com">test</a></h2>
<h2 id="text"><strong>text</strong></h2>
<h2 id="text-2"><em>text</em></h2>
<h2 id="text-3"><s>text</s></h2>\n`,
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Expand Up @@ -85,8 +85,10 @@ const treeToMarkdownBulletList = (tree, indent = 0) => tree.map(item => {
const indentation = " "
let node = `${ repeat(indentation, indent) }*`
if (item.heading.content) {
const contentWithoutAnchor
= item.heading.content.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
node += " " +
`[${ item.heading.content }](#${ item.heading.anchor })\n`
`[${ contentWithoutAnchor }](#${ item.heading.anchor })\n`
}
else {
node += "\n"
Expand Down

0 comments on commit a12433d

Please sign in to comment.