Forum How do I...?

hyphenation customizations

jbzech
Hi,

I have looked for documentation on how to customize my hyphenation dictionary, and I haven't found anything.

Here's what I've been doing: I've copied the hyphenation dictionary called "hyph-en-us.pat" into the folder with my content and pointed to this file in the CSS with the "prince-hyphenation-patterns" property. When I find something I want to customize, I go into the hyph-en-us.pat file and add a pattern. Given how complex this pattern document is, though, I'm always worried about fouling up other patterns by adding/removing. Is this the best way to customize my hyphenation patterns or is there a better way? I've found very little instruction on how to properly edit this document (just enough to think I know what I'm doing). Any suggestions?

I do like keeping the pattern dictionary with the content because it is all SVN-controlled, but if there is a better way to add custom hyphenation patterns, I'd love to hear about it.

Thanks,

jz
mikeday
This is probably the best way for the time being, yes. Customising your own hyphenation dictionary is still a bit of a black art. We may be able to simplify this with some kind of JavaScript API in the future, we'll see.
sakthikanth
Hi,

I have installed prince xml in local environment in ubuntu.

The hyphenation property works in local environment for tamil language when i add the below line in styles.css in prince source folder of style.

:lang(ta) { prince-hyphenate-patterns: url("../hyph/hyph-ta.pat"); }

and copied the file hyph-ta.pat to hyph folder in prince source folders.

And I have also using Docraptor API for generating documents.In that documents Hyphenation not working even when i added the below line in html content's style property

:lang(ta) { prince-hyphenate-patterns: url("../hyph/hyph-ta.pat");}

Is there any other requirements needed to work the hyphenation in Docraptor API ?

Thank You.



mikeday
I guess you will need to specify a HTTP URL for the hyphenation dictionary, or consult DocRaptor support.
sakthikanth
Sir,

Even though I changed the prince-hyphenate-patterns url to HTTP URL hyphenation not working .This is my document URL.

http://dev.jetpublish.com/sampledoc.html

Thank you
  1. sampledoc.html7.2 kB
    document content

Edited by sakthikanth

sakthikanth
Hi ,

Could you please let me know if remote urls work for connecting a hyphenation dictionary in PrinceXML 12?

The current document indicates only local paths: https://www.princexml.com/doc-prince/#hyphenation
mikeday
Sorry, you are quite right: Prince does not support remote HTTP URLs for hyphenation dictionaries yet!
mikeday
The latest builds now support loading hyphenation dictionaries from HTTP URLs, sorry it took so long. :)
timtribe
Taking this further, can -prince-hyphenate-patterns take an inline data uri (e.g. something like: url("data:text/plain;base64,JSB0aXRsZTogSHlwaGVuY...")? I cannot seem to get it to work.

Edited by timtribe

csant
The documentation cookbook has a broken URL - it'll be soon fixed...

But if you download the pattern file, convert that to a base64 data: URI, and place the supercalifragilisticexpialidocious example (make that word as long as you wish) into an h1 element, enable hyphens with
* { hyphens: auto; }
, and run prince to convert the file, it all works as expected for me.
timtribe
Thanks csant. I will continue to play with it.
Do you use the text/plain mime type?
e.g. url("data:text/plain;base64,JSB0aXRsZTogSHlwaGVuY...")
csant
I converted the pattern file linked above with this online converter and used text/plain.

data:text/plain;base64,LmFiNGkKLmFiM29sCi...

Edited by csant

timtribe
great, thanks