Albert, would this python solution insert a soft hyphen in every Str element? /bpj Den 18 nov 2016 20:20 skrev "Albert Krewinkel" : > Jürgen Schulze <1manfactory-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > > > Hello, I would like the hyphenation abilities of pandoc when generating > PDF > > documents to use for simple text/html files where the hyphenation is > inserted > > with entity "­". > > > > Something like > > > > pandoc --smart --wrap=none text.txt -o text2.txt > > > > How can this be done? > > One method would be to rely on the CSS `hyphens` property. Unforunately, > that property is not supported by Chrome/Webkit, so an additional > polyfill library like [Hyphenator](https://github.com/mnater/Hyphenator) > would be required. > > Alternatively, a pandoc filters can insert soft hyphens directly. > You'll need to install the python libraries `panflute` and `pyphen`. > Put the following code into a file and call it as a pandoc filter. > > > #!/usr/bin/env python3 > from panflute import * > import pyphen > > dic = pyphen.Pyphen(lang='en_US') > > def hyphenate(inline, doc): > if type(inline) == Str: > hyphenated = dic.inserted(inline.text, hyphen='­') > return Str(hyphenated) > > if __name__ == "__main__": > toJSONFilter(hyphenate) > > > The above code uses the unicode soft hyphen instead of the HTML entity, > which helps keeping the filesize low. Just change the `hyphen` > parameter if that's not what you want. > > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > > -- > You received this message because you are subscribed to the Google Groups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/ > msgid/pandoc-discuss/877f80h9x3.fsf%40espresso.zeitkraut.de. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAFC_yuTXVxsc0uUk2RjdDLG4tqGGK09GCZroNf_UFAdiyjr22A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.