Summary: Use the excellent Hyphenopoly package to hyphenate text on a wiki.
Version: 2020-08-21
Prerequisites: Recent version of pmwiki
Status: Maintained
Maintainer: Said Achmiz
License: MIT
Categories: Layout Publishing
Users: (view? / edit)
Discussion: Hyphenopoly-Talk?

Questions answered by this recipe

I want text on my wiki to be hyphenated, but some browsers/platforms do not support hyphenation; and those that do, use inferior hyphenation algorithms. I want good hyphenation on all (modern) browsers and platforms!


This recipe explains how to use the Hyphenopoly package to add JavaScript-based client-side hyphenation to your wiki.


  1. Go to https://github.com/mnater/Hyphenopoly; download and unzip the files.
  2. In your pub/ directory create a directory called hyphenopoly.
  3. Into pub/hyphenopoly/ upload the files Hyphenopoly_Loader.js, Hyphenopoly.js, and the patterns directory.

You should now have:

        |---(... more .wasm files for other languages ...)
  1. To your config.php add the following:
if ($action == 'browse' || $action == 'print') {
	global $HTMLHeaderFmt;
	$HTMLHeaderFmt[] = "
		var Hyphenopoly = {
			require: {
			setup: {
				selectors: {
					'#wikitext': {}
		<script src='$FarmPubDirUrl/hyphenopoly/Hyphenopoly_Loader.js'></script>
	global $HTMLStylesFmt;
	$HTMLStylesFmt[] = "
		p, ul, ol {
			-webkit-hyphens: auto;
			-moz-hyphens: auto;
			-ms-hyphens: auto;
			hyphens: auto;


Support for languages other than English

The code block given above adds hyphenation for English only. See the instructions at https://github.com/mnater/Hyphenopoly for adding support for other languages.

Hyphenating other HTML elements

The code block given above specifies hyphenation only for p, ul, and ol elements. To add hyphenation for more elements (e.g. blockquotes, etc.), modify the CSS snippet appropriately. Example:

	$HTMLStylesFmt[] = "
		p, ul, ol, blockquote {
			-webkit-hyphens: auto;
			-moz-hyphens: auto;
			-ms-hyphens: auto;
			hyphens: auto;

(The rest of the code should be unchanged.)

Hyphenation for other wiki actions

The code block given above will automatically hyphenate text when viewing a page (the browse action) or using the print view (the print action). If you want to enable hyphenation for other actions, modify the if statement appropriately. Example:

if ($action == 'browse' || $action == 'print' || $action == 'discuss') {

(The rest of the code should be unchanged.)


Hyphenation is automatic once configured as described above. No editing of wiki markup is needed.


To do / some day / maybe

  • Add some of the configuration options and features provided by JustHyp.

Change log / Release notes

  • 2020-08-21 - Initial release.

See also

JustHyp provided similar functionality. However, the recipe is currently broken on recent versions of PHP, and has other problems; it also requires the use of jQuery, and is thus relatively ‘heavyweight’, as well as having many different configuration options and features. In contrast, this recipe is very ‘lightweight’ and simple to use.



See discussion at Hyphenopoly-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.