00284: code samples treat \ escape as an escape

Summary: code samples treat \ escape as an escape
Created: 2005-01-13 09:39
Status: Closed - answered
Category:
From: Profiles
Assigned:
Priority: 0
Version: 2
OS:

Description: We use pmwiki extensively for documentation. When including a piece of code or a config file, we prefix the line with a space both for the hightlighting and for fixed width font.

e.g. here is part of the logrotate config for apache

        sharedscripts
        postrotate
           if [ -f /var/run/apache.pid ]; then \
             if [ -x /usr/sbin/invoke-rc.d ]; then \
                invoke-rc.d apache reload > /dev/null; \
             else \
                /etc/init.d/apache reload > /dev/null; \
             fi; \
           fi;
        endscript

This displays badly because the \ is not shown as a \. Instead it appears to be escaping the newline. Ack!

This is a documented and wanted behaviour. See TextFormattingRules.
Sven Opitz

The easy solution is to escape the entire code or file excerpt, as in:

        
        sharedscripts
        postrotate
           if [ -f /var/run/apache.pid ]; then \
             if [ -x /usr/sbin/invoke-rc.d ]; then \
                invoke-rc.d apache reload > /dev/null; \
             else \
                /etc/init.d/apache reload > /dev/null; \
             fi; \
           fi;
        endscript
        

This will also prevent any other wiki markups or WikiWords in the excerpt from interfering with the display of the text. You might also take a look at Cookbook.Beautifier for other ways of displaying code. --Pm