[kramdown-users] using kramdown in xhtml
t_leitner at gmx.at
Fri Jun 11 01:55:31 EDT 2010
On Thu, 10 Jun 2010 09:15:12 -0700
Matt Neuburg <matt at tidbits.com> wrote:
> > I won't implement this on Ruby 1.8 because of the lack of string
> > encoding support. However, the feature you want is already on my
> > TODO list. It will convert entities, smart quotes and typographic
> > symbols (as handled by the kramdown parser) into their character
> > equivalences on output - but only under Ruby 1.9. One more
> > incentive to switch from 1.8 to 1.9 ;-)
> Ouch! :) So I take it that iconv doesn't count as string encoding
> support? Oh, wait - you mean that you can't count on kramdown
> *itself* (i.e. literal strings in the kramdown file) being
> interpreted properly with respect to encoding. TextMate will
> interpret Ruby files as UTF-8; that's what I use, so I'm used to
> that, and I rely on the assumption that that's what I *will* use. But
> someone might run kramdown in some other milieu. I never thought of
> that. :)))
As far as I know iconv can only transcode strings from one encoding to
another, given you know the *source* encoding. But this source encoding
is not known in Ruby 1.8.
I had several choices regarding encodings:
* UTF-8 only: UTF-8 is supported by Ruby 1.8 and Ruby 1.9 with the
difference that in Ruby 1.8 one has to assume that the input is UTF-8
and in Ruby 1.9 one knows whether the input is in UTF-8. However, I
felt that this would limit the usefulness of kramdown to much,
especially in Asia.
* Supporting meta data and an encoding attribute: I once considered
this but I though that the last approach was still more useful.
* Just using whatever the user gives to kramdown and outputting it in
the same encoding. This is by far the easiest way, in Ruby 1.8 and
1.9. The only difference between 1.8 and 1.9 is that in 1.9 kramdown
knows the encoding whereas in 1.8 kramdown can only assume that the
string is ASCII compatible.
So basically the user needs to make sure that the string is in the
correct encoding before it is given to kramdown.
Regarding kramdown itself: all source files have the "encoding: utf-8"
tag for compatibility with Ruby 1.9 and all strings should be ASCII
Last but not least: multiple encoding support is currently not really
tested... however, nobody filed a bug so I presume that it works
More information about the kramdown-users