Skip to content

Support Vietnamsese when generating header ID#35

Closed
icy wants to merge 4 commits intogettalong:masterfrom
icyfork:vietnamese_ids
Closed

Support Vietnamsese when generating header ID#35
icy wants to merge 4 commits intogettalong:masterfrom
icyfork:vietnamese_ids

Conversation

@icy
Copy link

@icy 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 4 commits February 9, 2013 14:33
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
@ghost ghost assigned gettalong Feb 13, 2013
@gettalong
Copy link
Owner

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
Copy link
Author

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

@gettalong
Copy link
Owner

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!

@gettalong
Copy link
Owner

Fixed with commit a2bcbab.

@gettalong gettalong closed this Mar 9, 2013
@icy
Copy link
Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants