gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 275 forks source link

Allow the text surrounded by square brackets with IAL to convert to the span element. #726

Closed akinori-ichigo closed 2 years ago

akinori-ichigo commented 3 years ago

I made it to convert the text surrounded in square brackets with IAL to a plain span element. For example, "This is [CLASS_A]{:.class-a} text. This is [NO IAL] text." is converted to "\<p>This is \<span class="class-a">CLASS_A\</span> text. This is [NO IAL] text.\</p>". I think this feature get kramdown more expressive and useful.

gettalong commented 3 years ago

This conflicts with current syntax:

This is [Class_a]{:class-a} test other.

[Class_a]: link.html

Output:

<p>This is <a href="link.html">Class_a</a> test other.</p>

The IAL is not applied to the link which should probably be done but besides that changing the syntax is not possible.

akinori-ichigo commented 3 years ago

I think the IAL has been applied to the link in Kramdown 2.3.1:

$ gem list kramdown

*** LOCAL GEMS ***

kramdown (2.3.1)

$ pry
[1] pry(main)> require "kramdown"
=> true
[2] pry(main)> Kramdown::Document.new(<<EOS).to_html
[2] pry(main)* This is [Class_a]{:.class-a} test other.
[2] pry(main)* 
[2] pry(main)* [Class_a]: link.html
[2] pry(main)* EOS
=> "<p>This is <a href=\"link.html\" class=\"class-a\">Class_a</a> test other.</p>\n\n"
[3] pry(main)> 
cabo commented 3 years ago

So is there any other way to apply an IAL to an otherwise un-markedup text span?

gettalong commented 3 years ago

@cabo No, there is no such markup in kramdown. You would need to define a custom markup for this.