Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Support Vietnamsese when generating header ID #35

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
2 participants

icy commented Feb 10, 2013

Support Vietnamsese when generating header ID

If this option is true (and when auto_ids is true) ID values in
Vietnamese will be converted to a readable form (non-accent version
of the origin text).

This option should be used only if auto_ids is true.

Example: "Đây-là-ví-dụ" will generate new ID day-la-vi-du which is very
readable by Vietnamese. When this option is false, its ID should be
y-l-v-d which is unreadable (non-sense ID).

Default: true
Used by: HTML/Latex convertor

icy added some commits Feb 9, 2013

(generate_id) support Vietnamese accents
Vietnamese chars with accents will be converted to non-accent verion
that help the link id (anchor name) readable
Add new option :vietnamse_ids (default: true)
User can turn on/off the vietnamese support for (generate_id).

Add/fix test files to ensure the new option work correctly

@ghost ghost assigned gettalong Feb 13, 2013

Owner

gettalong commented Feb 13, 2013

Thanks for this pull request!

However, adding a language-specific option like this is probably not a good thing because then kramdown would need to add options for other languages like German or French too.

The one-size-fits-all solution would be to use something like https://github.com/rsl/stringex for doing the actual transliterations. When given your example string, the same result is output. So it should work fine for Vietnamese.

A problem with using stringex is, however, that it is tailored to be used in a Rails setting - not optimal for a normal Ruby library. Therefore I would probably just include the relevant parts in kramdown and update the data files from time to time.

What this be okay for your use case?

icy commented Feb 14, 2013

Thank you for the feedback.

I also think that my pull would mess up the Kramdown (I can see that when writting some test cases for the pull). Something like Stringex would be much better and it can generate readable IDs that I want.

So please consider to add support for Stringex (and of course, close my pull request ;)

Thank you very much

Owner

gettalong commented Mar 9, 2013

I have written an adapted version of the decoding routine from stringex (i.e. no code from the stringex library is directly used) and the data files from stringex (I don't think that shipping that 750KiB of data with kramdown is necessary).

With these changes your stated use case works flawlessly.

Note that this won't work on Ruby <=1.8.6!

Owner

gettalong commented Mar 9, 2013

Fixed with commit a2bcbab.

@gettalong gettalong closed this Mar 9, 2013

icy commented Mar 10, 2013

That's perfect. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment