wikicloth icon indicating copy to clipboard operation
wikicloth copied to clipboard

External links in ToC are not rendered as expected

Open kmotsov opened this issue 10 years ago • 4 comments

This is how links in headings are being rendered in ToC on mediawiki.org:

screenshot from 2014-07-24 12 15 56

And this is how the same markup is rendered on github.com:

screenshot from 2014-07-24 12 15 11

The markup is:

== [https://github.com/nricciar/wikicloth Heading 2] ==

== [https://github.com/nricciar/wikicloth Heading 2] ==

=== [https://github.com/nricciar/wikicloth Heading 3] ===

==== [https://github.com/nricciar/wikicloth Heading 4] ====

===== [https://github.com/nricciar/wikicloth Heading 5] ===== 

kmotsov avatar Jul 24 '14 09:07 kmotsov

This is a problem with github directly, not wikicloth. Github handles the link markup e.g. [ ] directly so wikicloth never even sees it.

nricciar avatar Jul 24 '14 17:07 nricciar

Hi nricciar,

Thank you for the great work on the gem. I just gave GitHub for example. On a clean rails app with the latest version of the gem (0.8.1) the following code produces the same markup:

text = <<-eos
== [https://github.com/nricciar/wikicloth Heading 2] ==

== [https://github.com/nricciar/wikicloth Heading 2] ==

=== [https://github.com/nricciar/wikicloth Heading 3] ===

==== [https://github.com/nricciar/wikicloth Heading 4] ====

===== [https://github.com/nricciar/wikicloth Heading 5] =====
eos

parser = ::WikiCloth::Parser.new(:data => text, :noedit => true)
parser.to_html

Which is different from what is rendered on mediawiki.org. Don't you think the gem should follow mediawiki.org's way of rendering.

Regards, Krum

kmotsov avatar Jul 25 '14 07:07 kmotsov

hmm yea looks like your right, although this may prove kinda complicated to fix. Problem exists because the table of contents is effectively generated prior to parsing the page so the content within the == == tags never gets parsed.

Re-opened this issue though as its definitely a bug sorry about jumping to conclusions :)

nricciar avatar Jul 25 '14 14:07 nricciar

+1 Note that this is also occurring for internal links (as in gollum).

dometto avatar Dec 29 '14 12:12 dometto