NAME

hyphenate_html

USAGE

hyphenate_html [--length 10] [--start 2] [--end 2] [--lang en_US] index.html

hyphenate_html [--excluded] [--incl class1] [--incl class2] index.html

OPTIONS

  • length: minimal length of a word that will be hyphenated. Defaults to 10.

  • start: minimum number of characters at the start of a word that won't be hyphenated. Defaults to 2.

  • end: minimum number of characters at the end of a word that won't be hyphenated. Defaults to 2.

  • lang: default language used for hyphenation when a language isn't defined in the document itself. Defaults to en_US.

  • excluded: determine if nodes are to be hyphenated by default or need to have it's class specified by the incl option. Defaults to false so without further classes given to include or exclude in the next options the content of all nodes is hyphenated. This is only to limit the number of soft hyphens added to the document: whether they are used to break words can and should be set using the CSS applied to the HTML.

  • incl: classes of nodes that should have it's contents hyphenated.

  • excl: classes of nodes that should not have it's contents hyphenated when excluded is not set.

  • input: input file. Defaults to standard input.

  • output: output file. Defaults to standard output.

DESCRIPTION

Inserts soft hyphens in the words in an HTML document to get more control over at what position words are allowed to break and wrap over multiple lines when rendered in a browser.

REQUIRED ARGUMENTS

There are no required arguments.

DIAGNOSTICS

It dies with an error message when the input or output doesn't behave as expected.

EXIT STATUS

Nothing special.

CONFIGURATION

There is no configuration.

DEPENDENCIES

It depends on HTML::Hyphenate, Getopt::Long and Pod::Usage.

INCOMPATIBILITIES

There are no known incompatibilities.

BUGS AND LIMITATIONS

  • Perfect hyphenation can be more complicated than just inserting a hyphen somewhere in a word, and sometimes requires semantics to get it right. For example cafeetje should be hyphenated as cafe-tje and not cafee-tje and buurtje can be hyphenated as buur-tje or buurt-je, depending on it's meaning. While HTML could provide a bit more context (mainly the language being used) than plain text to handle these issues, the initial purpose of this module is to make it possible for HTML rendering engines that support soft hyphens to be able to break long words over multiple lines to avoid unwanted overflow.

  • The hyphenation doesn't get better than TeX::Hyphenate and it's hyphenation patterns provide.

  • The round trip from HTML source via Mojo::DOM to HTML source might introduce changes to the source, for example accented characters might be transformed to HTML encoded entity equivalents or Boolean attributes are converted to a different notation.

Please report any bugs or feature requests at RT for rt.cpan.org.

AUTHOR

Roland van Ipenburg, <roland@rolandvanipenburg.com>

LICENSE AND COPYRIGHT

Copyright (C) 2009-2020, Roland van Ipenburg

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.0 or, at your option, any later version of Perl 5 you may have available.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.