Hello, I decided to give your soulution a try.
When running
pandoc -s in.txt --filter hyphfilter.py -o out.txt
I get this:
pandoc: Error running filter hyphfilter.py
hyphfilter.py: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
What am I doing wrong?
I have no clue about Python.

Juergen


Am Freitag, 18. November 2016 20:20:51 UTC+1 schrieb Albert Krewinkel:
Jürgen Schulze <1manf...-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 "&shy;".
>
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/112f7607-4771-4672-924d-98850eba8616%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.