[kramdown-users] [ANN] kramdown 0.9.0 released

Eric Sunshine sunshine at sunshineco.com
Sat Jul 17 06:07:06 EDT 2010


On 7/17/2010 5:19 AM, Thomas Leitner wrote:
>>>> C:\>kramdown test.kd>   test.html
>>>> c:/ruby/lib/ruby/gems/1.9.1/gems/kramdown-0.9.0/lib/kramdown/parser/kramdown.rb:206:in
>>>> `check': incompatible encoding regexp match (UTF-8 regexp with
>>>> IBM437 string) (Encoding::CompatibilityError)
>>> Hmm... I have to look at this, and probably generate some test cases
>>> for checking encodings under Ruby 1.9. Could you send me the test.kd
>>> document so that I can dig into it and find the offending regexp?
>> I narrowed it down to this fragment:
>>     <p>Fran&#xE7;ois</p>
>> The equivalent<p>Fran&ccedil;ois</p>  is converted to kramdown and
>> back to HTML without problem.
> I have tried to reproduce the problem but wasn't successful.

I also could not reproduce the problem with that input. I may have 
simplified it too much, though I was certain that I had tested and 
re-tested before posting. Changing the 'p' tag to an 'a', however, does 
reproduce the problem:

     <a href="">Fran&#xE7;ois</a>

kramdown converts this input to:

     [François]()

which has IBM437 encoding on Windows (US/English version). When 
converted back to HTML, the above error occurs.

> I have used the following test program (named `tt.rb`):
> require 'kramdown'
> text = "Fran&#xE7;ois"
> text.force_encoding('IBM437')
> p [text.encoding, Encoding.default_internal, Encoding.default_external]
> puts Kramdown::Document.new(text).to_html
>      $ ruby tt.rb
>      [#<Encoding:IBM437>, nil, #<Encoding:UTF-8>]
>      <p>Fran�ois</p>
> where the question mark character is ccedil in the IBM437 encoding.

I can reproduce the crash on Windows with a slightly modified version of 
your program where a Markdown "link" with embedded ccedil is assigned to 
'text':

     require 'kramdown'
     text = '[François]()'
     text.force_encoding('IBM437')
     p [text.encoding,
         Encoding.default_internal, Encoding.default_external]
     puts Kramdown::Document.new(text).to_html

     C:\>ruby tt.rb
     [#<Encoding:IBM437>, nil, #<Encoding:IBM437>]
 
c:/ruby/lib/ruby/gems/1.9.1/gems/kramdown-0.9.0/lib/kramdown/parser/kramdown.rb:206:in 
`check': incompatible encoding regexp match (UTF-8 regexp with IBM437 
string) (Encoding::CompatibilityError)


By the way, while revisiting this issue, I discovered a kramdown 
crasher. When feeding it HTML containing a named anchor (with no 'href'):

     <a name="example">Anchor</a>

it crashes attempting to invoke a method on nil:

     C:\>kramdown -i html -o kramdown anchor.html
 
c:/ruby/lib/ruby/gems/1.9.1/gems/kramdown-0.9.0/lib/kramdown/converter/kramdown.rb:278:in 
`convert_a': undefined method `empty?' for nil:NilClass (NoMethodError)

-- ES


More information about the kramdown-users mailing list