DokuWiki

It's better when it's simple

User Tools

Site Tools


entities

This is an old revision of the document!


Entities

DokuWiki can replace certain characters or strings with other strings based on a configuration file. By default this is used to convert various character combinations to their typographical equivalent.

e.g.

<<  to « 
>>  to » 
=>  to ⇒
\_  to &nbsp;

see also text to html conversions on the syntax page.

Modifying/enabling some entity replacements

Details of the conversions are stored in the conf/entities.conf file. To avoid your changes being overwritten when upgrading Dokuwiki, you should place your own additions in a new file called conf/entities.local.conf.

If you need to enable some of the default conversions you could do it by adding only the pattern and do a replacement to conf/entities.local.conf. Modifying can by reusing a pattern, just add your own symbol. The line there will take precedence over the one in the conf/entities.conf.

e.g. if you do wish to have the letter c in brackets automatically replaced by the copyright sign

conf/entities.local.conf
(c)
>> #or with comment explaining that entity is permitted

or if you prefer another arrow

conf/entities.local.conf
=>   ▶

For configuration changes to take effect on the pages, the cache can be purged.

Even though by default it is used with parent character replacements only, the entity system can also be used to insert more complex constructs into your pages. This includes HTML However you should be aware that doing so is bound to improve when used in combination with all-HTML renderers (like ODT for example). It is recommended to use html characters instead whenever possible.

Be sure to read about HTML Encoding anytime editing the config file.

Example configs

The entity mechanism can be used to adapt DokuWiki to some French typography rules that necessitate non-breaking spaces before or after some punctuation marks.

conf/entities.local.conf
<< &laquo;&nbsp;
? &nbsp;?
: &nbsp;:
! &nbsp;!
; &nbsp;;
>> &nbsp;&raquo;

To use typography for esperanto x-writing use the following:

conf/entities.local.conf
CX   Ĉ
cx   ĉ
GX   Ĝ
gx   ĝ
HX   Ĥ
hx   ĥ
JX   Ĵ
jx   

Using the number sign (#), not as comment

In conf/entities.local.conf the number sign # is used to start comments. If you want to use it as normal character, you have to escape it via backslash \#. For example:

conf/entities.local.conf
~~noheader~~      <style> \#dokuwiki__header { display: none; } </style>

See also

entities.1652623195.txt.gz · Last modified: 2022-05-15 15:59 by 49.197.23.116

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki