/
SpacedWikiWordPlugin.txt
125 lines (95 loc) · 6.81 KB
/
SpacedWikiWordPlugin.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
%META:TOPICINFO{author="ProjectContributor" date="1081752098" format="1.0" version="1.1"}%
---+!! %TOPIC%
<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->
Automatically display topic links spaced out: [[[%TOPIC%]] is displayed as %SPACEOUT{"%TOPIC%"}%.
*AND/OR*
Display "underscore topic names" like [[%TOPIC%][Topic_name]] as [[%TOPIC%][Topic name]].
This plugin also overrides the core =SPACEOUT= macro to improve the presentation
of spaced out words, and allow for a =DONTSPACE= list.
%TOC%
---++ Options
Spaced out !WikiWords definitely make links more readable, but they can also produce "Odd Looking Sentence Case" links.
Use underscore topic names if you want total control over links:
1 (Optionally) disable automatic linking of !WikiWords. Do this if you are in the position to teach your users to only write links in bracket notation like =[<nop>[WebHome]]=. This is also how Wikipedia links are written. Bracket notation is necessary to create links for underscore topic names, but you can also mix both link notations.
* In [[%USERSWEB%.SitePreferences]] write =[3 spaces]* Set NOAUTOLINK = on=
1 Use bracket notation without explicit link labels:
* =[<nop>[WebHome][WebHome]]= - explicit link label, no spacing out
* =[<nop>[WebHome]]= - link is label, so no explicit link label: this is spaced out
1 Use underscores to create natural looking links:
* A topic name such as =[<nop>[Human_evolution]]= will be rendered as [[%TOPIC%][Human evolution]]
* Plain topic names like =Human_evolution= are not expanded; always use bracket notation
wiki words are automatically spaced out. Automatically spaced out are: =TopicName=, =Web.TopicName=, =[<nop>[TopicName]]=.
Explicitly written link labels are *not* spaced out. Examples: =[<nop>[TopicName][TopicName]]= or =[<nop>[TopicName][SomeOtherName]]=.
---+++ Underscore links
=[<nop>[Underscore_topic]]= is automaticlly spaced out (but not =Underscore_topic=).
#SearchResults
---+++ Spacing out search results
Use the =[[VarSPACEOUT][SPACEOUT]]= macro. For example, write:
<verbatim>
[[$web.$topic][$percntSPACEOUT{$topic}$percnt]]
</verbatim>
to generate: %SEARCH{"%TOPIC%" scope="topic" nonoise="on" format="[[$web.$topic][$percntSPACEOUT{$topic}$percnt]]"}%
More info on search syntax in [[FormattedSearch]].
#PreventingSpaceOut
---+++ Preventing spacing out of some words
Some words (often brand names and medical terms) are written in [[Wikipedia:CamelCase][CamelCase]] notation and should not be spaced out. For example: !CamelCase, !DaimlerChrysler, !MasterCard.
Define a list of words that should not get spaced out with =DONTSPACE= in your prefereces.
---++ Troubleshooting
---+++ My links are not spaced out
* At [[#PluginTest][Plugin test]] below, check if this plugin is enabled and if the correct spacing settings are applied.
* You have used an explicit link label: with =[<nop>[WebHome][WebHome]]=, "WebHome" is not spaced out. Use =[<nop>[WebHome]]= or =[<nop>[WebHome][%<nop>SPACEOUT{"WebHome"}%]]=
* You have used underscore topic names without bracket notation. Always write =[<nop>[Human_evolution]]=
* You are showing links from a search result. See [[#SearchResults]] above.
---+++ Some words are spaced out, but shouldn't be
See [[#PreventingSpaceOut]].
#PluginSettings
---++ Settings
You can control the behaviour of the plugin using the following PreferenceSettings:
* =DONTSPACE= can be set to a commaa-separated list of words that should not be spaced out
* =SPACE_OUT_WIKI_WORD_LINKS= can be set to 1/0 to enable/disable spacing out =WikiWord= links to =Wiki Word= links
* =SPACE_OUT_UNDERSCORE_LINKS= can be set to 1/0 to enable/disable spacing out =Topic_name= links to =Topic name= links
* =REMOVE_ANCHOR_DASHES= can be set to 1/0 to enable/disable removing anchor dashes when writing =[<nop>[#SomeAnchor]]=
All these settings are on by default.
---++ Tests
#TestHere
If the plugin is installed and enabled:
<!--
* Set SPACE_OUT_WIKI_WORD_LINKS = %URLPARAM{"SPACE_OUT_WIKI_WORD_LINKS" default="0"}%
* Set SPACE_OUT_UNDERSCORE_LINKS = %URLPARAM{"SPACE_OUT_UNDERSCORE_LINKS" default="0"}%
* Set REMOVE_ANCHOR_DASHES = %URLPARAM{"REMOVE_ANCHOR_DASHES" default="0"}%
* Set DONTSPACE = %URLPARAM{"DONTSPACE"}%
-->
<form method="post" action="%SCRIPTURL{"view" web="%WEB%" topic="%TOPIC%" #="Tests"}%">
* SPACE_OUT_WIKI_WORD_LINKS <input type="checkbox" name="SPACE_OUT_WIKI_WORD_LINKS" value="1" %IF{"$SPACE_OUT_WIKI_WORD_LINKS" then="checked"}%>
* SPACE_OUT_UNDERSCORE_LINKS <input type="checkbox" name="SPACE_OUT_UNDERSCORE_LINKS" value="1" %IF{"$SPACE_OUT_UNDERSCORE_LINKS" then="checked"}%>
* REMOVE_ANCHOR_DASHES <input type="checkbox" name="REMOVE_ANCHOR_DASHES" value="1" %IF{"$REMOVE_ANCHOR_DASHES" then="checked"}%>
* DONTSPACE (comma-separated list of things not to space) <input name="DONTSPACE" value="%DONTSPACE%" size="50"}%>
<input type="submit" value="Refresh">
</form>
* Plain Wikiword: %TOPIC%, ODDsAndEnds, AsYouLikeIt, JustAMinute
* Wikiword in brackets: [[%TOPIC%]]
* !Underscore_topic link: [[Spaced_Wiki_Word_Plugin]]
* Anchor dashes: [[#TestHere]]
* Pluralised ACRONYMs like [[JETs]] should not be spaced
* =%<nop>SPACEOUT{"WishUponAStar"}%=: %SPACEOUT{"WishUponAStar"}%
---++ Installation Instructions
%X% WARNING: this plugin is designed for Foswiki 2.0 and later. It may work on some earlier Foswiki versions, but has not been tested with them.
%$INSTALL_INSTRUCTIONS%
---++ History
| 12 July 2017 | Crawford Currie: rewrote for Foswiki 2 |
| 10 Nov 2010 | Padraig Lennon: Foswikitask:Item9994 - Fix Release Version |
| 23 Nov 2007 | Arthur Clemens: made compatible to Foswiki; allow =DONTSPACE= to separated words by spaces. |
| 05 May 2007 | Arthur Clemens: fixed a wrong function call, thanks TWiki:Main.JohnFitzpatrick. |
| 04 May 2007 | Arthur Clemens: spacing out uses a Core function (from Plugins version 1.13; fallback for older versions); added support for spacing out of "underscore topic names"; added optional removal of anchor dashes. |
| 20 Apr 2007 | Arthur Clemens: updated with regexes from TWiki Core =spaceOutWikiWord=; added =DONTSPACE= option. |
| 12 Apr 2004 | Updated for TWiki 3 |
| 14 Apr 2002 | First release |
%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Foswiki:Main.MartinCleaver (2002, 2004), Foswiki:Main.ArthurClemens (2007, 2008), Foswiki:Main.CrawfordCurrie (2017)"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Repository" attributes="" title="Repository" value="https://github.com/foswiki/WorkFlowPlugin"}%
%META:FIELD{name="Support" attributes="" title="Support" value="http://foswiki.org/Support/SpacedWikiWordPlugin"}%
%META:FIELD{name="Home" attributes="" title="Home" value="http://foswiki.org/Extensions/SpacedWikiWordPlugin"}%