Beware of markup parsing in monospace formatting

Just wanted to point out a pitfall I discovered today:

If you use Dokuwiki's monospace formatting: ''monospace text goes here'' as an inline code block, you MUST also surround your text with %% e.g ''%%code%%''.

Without the %% surrounding the text, Dokuwiki markup still takes place, including insidious double dash replacement which will leave people very confused when their copy/pastes aren't working as expected.

Take for example, the following two flags which look nearly identical:

The first command uses a copy/paste from ''----netfilter-mode=off'' and would result in an error during argument parsing due to double dash replacement.

The second (correct form) uses a copy paste from ''%%--netfilter-mode=off%%''.

Paying attention to subtle details like this can really make a difference to somebody's day.

2 Likes

Yeah, that could bite your readers right in the butt. This behavior is a setting in conf/entities.conf, maybe the double-dash conversion should be turned off? (I'd also vote for turning off <<, >> and ---; maybe the "equal" arrows => and <=, too.)

$ cat conf/entities.conf
# Typography replacements
#
# Order does matter!
#
# You can use HTML entities here, but it is not recommended because it may break
# non-HTML renderers. Use UTF-8 chars directly instead.

<->     ↔
->      →
<-      ←
<=>     ⇔
=>      ⇒
<=      ⇐
>>      »
<<      «
---     —
--      –
(c)     ©
(tm)    ™
(r)     ®
...     …
1 Like

Oh, I didn’t even realize this was a tunable. I’ll do a quick survey of the page data and see if changing this setting would affect any pages negatively and then update the config. Thanks for pointing that out!

Yeah, I use dokuwiki at home and ran into exactly the same double-dash issue with a curl --output... command, then when I did something like echo blah >> file and that redirect got translated to », it bugged me so much I dug around and found the config file and "fixed" it for good.

1 Like

Use code tags instead:

I think that disabling at least -- entity replacement does make sense though, it is just too common when documenting cli flags and the like

2 Likes

An issue with the <code> syntax though, is that text can’t float to the right of it. Inline monospaced blocks with '' '' are really useful for emphasizing or differentiating text as code or jargon.

I’ll do a quick query in the db for any page data that could be impacted before modifying this setting.

It appears there are a handful of pages with the unicode em/en dash replacement which were clearly intended as GNU long options.

Here are some examples:

$ grep -Pr -- '–[a-z]' /var/www/dokuwiki/data/pages/*
data/pages/docs/guide-user/services/vpn/wireguard/serverclient.txt:In practice however, it often degrades to the [[wp>Client–server_model|client-server]] model due to IPv4 and NAT connectivity limitations and gateway firewall restrictions.
data/pages/docs/guide-user/services/vpn/start.txt:VPN typically relies on the [[wp>Client–server model|client-server]] model and works as L2TP or L3TP depending on the protocol and service configuration.
data/pages/docs/techref/hardware/port.serial.txt:Since your router is very likely to have its I/O pins working at 3.3V ([[wp>Transistor–transistor logic|TTL]] level voltage), you'll need [[docs:techref:hardware:port.serial#usb.to.rs232.ttl.converter.module]] or a level shifter such as a Maxim MAX232 to change the level from 3.3V to your computer level which is usually at 12V.
data/pages/es/toh/sagem/livebox.2.txt:Para conectarlo a nuestro ordenador necesitaremos un adaptador de [[docs:techref:hardware:port.serial|puerto serie]] [[wp>Transistor–transistor logic|TTL]].
data/pages/ko/docs/guide-user/firewall_configuration.txt:| ''extra'' | string | no | //(none)// | 추가 인수는 iptables에 직접 전달됩니다. 이러한 옵션은 소스 및 대상 분류 규칙으로 전달되므로 여기서는 -dport와 같은 –dport 별 옵션을 사용하면 안됩니다.이 경우에는 extra_src 및 extra_dest 옵션을 대신 사용해야합니다.   |
data/pages/toh/linksys/ag241.txt:Since your router is working at 3.3V ([[wp>Transistor–transistor logic|TTL]] level voltage), you'll need [[docs:techref:hardware:port.serial#usb.to.rs232.ttl.converter.module|USB to RS232 TTL converter]] or a level shifter such as a Maxim MAX232 to change the level from 3.3V to your computer level which is usually at 12V.
data/pages/toh/linksys/wag354g.txt:Since your router is working at 3.3V ([[wp>Transistor–transistor logic|TTL]] level voltage), you'll need [[docs:techref:hardware:port.serial#usb.to.rs232.ttl.converter.module|USB to RS232 TTL converter]] or a level shifter such as a Maxim MAX232 to change the level from 3.3V to your computer level which is usually at 12V.
data/pages/toh/d-link/dir-300.txt:For linux there is shell script called [[http://x-alina.freifunk-potsdam.de/downloads/dir300-flash/|dir300-flash]]; it wraps the manual steps for replacing the original bootloader and/or flashing firmware images into a single command line. The script requires a tftp-daemon to be already running. See –help for further details. Usage:
data/pages/zh/toh/linksys/wrt1900ac.txt:    * <color #789600>//**sudo –i**//</color>
data/pages/zh/toh/linksys/wrt1900ac.txt:      * 解压归档, 之后: <color #789600>//**tar –xvf kwboot.tar**//</color>
data/pages/zh/toh/linksys/wrt1900ac.txt:    * <color #789600>//**./kwboot –a –t /dev/ttyUSB0 –b u-boot-uart.kwb**//</color> **__并且__** //给路由器上电//
data/pages/zh/docs/guide-user/services/vpn/overview.txt:在两个或者多个主机间设置VPN,可以使用的软件包有很多种。它们都使用[[wp>Client–server model|Client-Server concept]],并且互相之间通常**不**兼容.
data/pages/zh/docs/techref/process.boot.txt:tts/0::askfirst:/bin/ash –login
data/pages/zh/docs/techref/process.boot.txt:ttyS0::askfirst:/bin/ash –login
data/pages/zh/docs/techref/process.boot.txt:tty1::askfirst:/bin/ash –login

I've gone and updated the conf/entities.local.conf with the following exclusions per https://www.dokuwiki.org/entities:

>>      # bash append operator confusion
<<      # bash redirect/herestring operator confusion
---     # GNU long option confusion
--      # GNU long option confusion
...     # unnecessary UTF-8 replacement

This also necessitated purging php cache.

If needed, this change can be reverted by removing these added lines in conf/entities.local.conf and running:

sudo touch /var/www/dokuwiki/inc/parser/xhtml.php
sudo touch /var/www/dokuwiki/conf/local.php
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.