kramdown / parser-gfm

kramdown-parser-gfm provides a kramdown parser for the GFM dialect of Markdown
Other
55 stars 14 forks source link

GFM parser not respecting the 'transliterated_header_ids' kramdown option #21

Closed kill9zombie closed 2 years ago

kill9zombie commented 3 years ago

While building a Jekyll site we came across an issue where header IDs were being generated in non-ascii character sets. Some content is Arabic, so obviously worse there. When using the kramdown parser the transliterated_header_ids option is respected.

To reproduce it:

#!/usr/bin/env ruby
# frozen-string-literal: true

require 'kramdown'
require 'kramdown-parser-gfm'
require 'stringex'

h1 = "# nossos serviços"

kramdown_html = Kramdown::Document.new(h1, :auto_ids => true, :transliterated_header_ids => true, :input => "kramdown").to_html

gfm_html = Kramdown::Document.new(h1, :auto_ids => true, :transliterated_header_ids => true, :input => "GFM").to_html

puts "input:\n#{h1}"
puts
puts "kramdown:\n#{kramdown_html}"
puts
puts "GFM:\n#{gfm_html}"

Output:

input:
# nossos serviços

kramdown:
<h1 id="nossos-servicos">nossos serviços</h1>

GFM:
<h1 id="nossos-serviços">nossos serviços</h1>

It looks like the GFM parser is adding an id attribute to the element before the kramdown converter gets a chance to transliterate the ID.

ashmaroli commented 2 years ago

Resolved via #22