Support Vietnamsese when generating header ID#35
Support Vietnamsese when generating header ID#35icy wants to merge 4 commits intogettalong:masterfrom
Conversation
Vietnamese chars with accents will be converted to non-accent verion that help the link id (anchor name) readable
User can turn on/off the vietnamese support for (generate_id). Add/fix test files to ensure the new option work correctly
|
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? |
|
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 |
|
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! |
|
Fixed with commit a2bcbab. |
|
That's perfect. Thank you very much. |
Support Vietnamsese when generating header ID
If this option is
true(and whenauto_idsis true) ID values inVietnamese will be converted to a readable form (non-accent version
of the origin text).
This option should be used only if
auto_idsis true.Example: "Đây-là-ví-dụ" will generate new ID
day-la-vi-duwhich is veryreadable by Vietnamese. When this option is
false, its ID should bey-l-v-dwhich is unreadable (non-sense ID).Default: true
Used by: HTML/Latex convertor