rdiscount icon indicating copy to clipboard operation
rdiscount copied to clipboard

rdiscount render same header id for all headers

Open lengerfulluse opened this issue 10 years ago • 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:
screen shot 2015-07-27 at 5 30 30 pm Any ideas? or did i miss some configuration? Thanks in advance!

lengerfulluse avatar Jul 28 '15 01:07 lengerfulluse

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.

davidfstr avatar Jul 29 '15 02:07 davidfstr

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.

davidfstr avatar Aug 06 '15 03:08 davidfstr

Thanks @davidfstr ! I just try it use UTF-8 Chinese characters. And it get the following result: screen shot 2015-08-08 at 22 29 33 The name is all the same L......

lengerfulluse avatar Aug 08 '15 14:08 lengerfulluse

I see your problem. I get similar results with the following input file, which is similar to yours: https://gist.github.com/davidfstr/94d086b036b3d10ab7ca

davidfstr avatar Aug 09 '15 05:08 davidfstr

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 .

davidfstr avatar Aug 09 '15 05:08 davidfstr

Issue is still present in (R)Discount 2.2.0. Left comment on upstream issue.

davidfstr avatar Apr 20 '16 05:04 davidfstr

Looks like this issue is now fixed upstream, so probably just need to upgrade the Discount processor to get the fix.

davidfstr avatar Apr 22 '21 15:04 davidfstr