rdiscount render same header id for all headers
lengerfulluse opened this issue · 7 comments
Hi guys, I try to generate table of content with rdiscount, and the _config.yml
file is:
markdown: rdiscount
rdiscount:
extensions:
- generate_toc
But i just found rdiscount seems render the same header id for all headers, please see the following screenshot:
Any ideas? or did i miss some configuration? Thanks in advance!
Well that's interesting. I don't believe I've ever tried the generate_toc option myself since inheriting the project. I'll take a look later this week - or later today if I find some time.
I am not able to reproduce your issue. I told RDiscount to format a string with :generate_toc and got distinct names for different headings.
Specifically I ran the following commands:
$ irb
2.0.0-p353 :002 > require 'rdiscount'
=> true
2.0.0-p353 :003 > rd = RDiscount.new("# Level 1\n\n## Level 2", :generate_toc)
=> #<RDiscount:0x007f87ba0c5780 @text="# Level 1\n\n## Level 2", @generate_toc=true>
2.0.0-p353 :004 > rd.to_html
=> "<a name=\"Level.1\"></a>\n<h1>Level 1</h1>\n\n<a name=\"Level.2\"></a>\n<h2>Level 2</h2>\n"
2.0.0-p353 :005 >
If you continue to have issues, please provide specific repro steps.
Thanks @davidfstr ! I just try it use UTF-8 Chinese characters. And it get the following result:
The name is all the same L......
I see your problem. I get similar results with the following input file, which is similar to yours:
https://gist.github.com/davidfstr/94d086b036b3d10ab7ca
I have also reproduced your problem with the underlying Discount tool:
$ ./markdown -f toc
# 中
## 学
####私
^D
<p>#</p>
<a name="L..."></a>
<h2>学</h2>
<a name="L..."></a>
<h4>私</h4>
Therefore I have filed an issue on Discount itself at Orc/discount#126 .
Issue is still present in (R)Discount 2.2.0. Left comment on upstream issue.
Looks like this issue is now fixed upstream, so probably just need to upgrade the Discount processor to get the fix.