SmartWordBreakPlugin
Inserts word-breaks and soft hyphens into long words
Usage
Long words like can really mess up table formatting, making your page an untidy mess,
because browsers tend not to split words. You can tell the browser that it may, by using the <wbr> tag,
but this tag is not supported by all browsers. In fact, there is
*no* completely portable way to do this.
Besides, you would rather concentrate on content and not on irritating details like where to split long words.
SmartWordBreakPlugin automatically inserts word-break markers for you.
It uses the correct form of word-break marker for your browser.
There are several reasons why words can end up long. WikiWords can be alarmly long e.g.
SmartWordBreakPlugin.
Long names tend to crop up in software source code and thus also in the corresponding documentation.
SmartWordBreakPlugin provides the SMARTWORDBREAK macro for selectively inserting word-breaks.
Alternatively, the SMARTWORDBREAKPLUGIN_WHOLEPAGE preference enables processing for the whole page,
but this can
hurt performance.
Examples
This table illustrates what
SmartWordBreakPlugin does (change the window width to see the effect):
%TABLE{columnwidths="30%,70%"}%
| *Selection* | *Manifestation* |
| %SMARTWORDBREAK{Navigate_With_Euclidean_Geometry}% | Works for short distances, based on the approximation that the world is flat. |
| %SMARTWORDBREAK{Navigate_With_Elliptical_Geometry}% | Works for long distances. |
Simulation (works on Firefox 2 & 3, IE 6 & 7):
| Selection |
Manifestation |
| Navigate_With_Euclidean_Geometry |
Works for short distances, based on the approximation that the world is flat. |
| Navigate_With_Elliptical_Geometry |
Works for long distances. |
If you have the plugin installed and enabled:
| Selection |
Manifestation |
| %SMARTWORDBREAK{Navigate_With_Euclidean_Geometry}% |
Works for short distances, based on the approximation that the world is flat. |
| %SMARTWORDBREAK{Navigate_With_Elliptical_Geometry}% |
Works for long distances. |
Without word-breaks:
| Selection |
Manifestation |
| Navigate_With_Euclidean_Geometry |
Works for short distances, based on the approximation that the world is flat. |
| Navigate_With_Elliptical_Geometry |
Works for long distances. |
%SMARTWORDBREAK{Long_Name}% produces Long_<wbr>Name.
The
longest parameter specifies the maximum number of characters between word-breaks.
Thus, %SMARTWORDBREAK{"Mathematical Excursions" longest="7"}% produces Mathema<wbr>
Typical use
Add this to specific pages to make
SmartWordBreakPlugin process the whole of the page (probably the best way to use this plugin):
<!--
* Set SMARTWORDBREAKPLUGIN_WHOLEPAGE=1
-->
Caveats
Browsers do not all wrap text in the same way. Some browsers only respect word-breaks for text in tables.
Others respect word-breaks for all text.
SmartWordBreakPlugin does not understand lanuage; it does not try to split long words at hyphenation points.
It simply chops up really-long words into fixed-length seqments
For example,
%SMARTWORDBREAKPLUGIN{protoexistentialist}% produces
protoexistentia<wbr>list with the default settings.
%SMARTWORDBREAK{}% breaks the automatic conversion of wikiwords into links.
SmartWordBreakPlugin can hurt performance. It is better to use it only where it is needed.
Use %SMARTWORDBREAK{}% in preference to setting SMARTWORDBREAKPLUGIN_WHOLEPAGE to true.
Set SMARTWORDBREAKPLUGIN_WHOLEPAGE to true for a single page in preference to setting it true for a whole web.
Set it to true for a single web in preference to setting it true for a whole site.
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available in
configure, then you can still install manually from the command-line. See
http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Preferences
No preferences are stored in this topic. The example settings here have no effect.
To learn more about setting preference variables, see the
PreferenceSettings topic.
| Variable |
Default |
Description |
SMARTWORDBREAKPLUGIN_WHOLEPAGE |
false |
Enables processing of the whole web page. Word-breaks are inserted in link text, but links still point to the same places. This works better than %SMARTWORDBREAK{}%, but it is slower, so this preference should only be set on the pages where it is needed. |
SMARTWORDBREAKPLUGIN_LONGEST |
15 |
Sets the length of the longest unbroken sequence of letters. This preference affects the whole page when using the SMARTWORDBREAKPLUGIN_WHOLEPAGE setting. It also sets the default for the longest parameter to %SMARTWORDBREAK{}%. |
SMARTWORDBREAKPLUGIN_NEEDS_UNICODE_WBR |
(?i-xsm:Opera|MSIE 8) |
Specifies when to use a unicode character instead of a <wbr> tag. It may be a regular expression, which is applied to the user-agent string from the browser, or it may be a boolean value. If it is a regular expression, and it matches the user-agent string, then SmartWordBreakPlugin inserts unicode character 8203 instead of wbr tags. If it has a boolean-type value (e.g. true, false, 1 or 0), and it is false, then SmartWordBreakPlugin never inserts unicode word-break characters. If it is a boolean-type true value, then SmartWordBreakPlugin always inserts unicode word-break characters instead of wbr tags. |
SMARTWORDBREAKPLUGIN_NEEDS_SPAN_WBR |
false |
Similar to SMARTWORDBREAKPLUGIN_NEEDS_UNICODE_WBR, but it controls the insertion of narrow <span>s instead of <wbr> tags. Only one of SMARTWORDBREAKPLUGIN_NEEDS_UNICODE_WBR and SMARTWORDBREAKPLUGIN_NEEDS_SPAN_WBR should ever be active at a time. (You won't break anything if you do, but the behaviour is not specified so don't depend on it.) |
Info