Double Hyphen in Wordpress
Before migrating to Octopress (and later to Hugo), this blog was written in Wordpress. Every time I
posted a tutorial with commands that have options with double hyphens (example: ls --all),
Wordpress formatted the two consecutive hyphens (--) as a single dash (—). This probably
confused the reader (e.g., ls --all), and also prevented the code from simply being copied from
the blog and pasted into the terminal.
We can change this configuration directly in the Wordpress source code.
Edit the
static_charactersarray, contained in the filewp-includes/formatting.phpjuliobor@box780 ~ $ vim www/blog/wp-includes/formatting.php
Before:
$static_characters = array_merge( array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney );
$static_replacements = array_merge( array($em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace );
After:
$static_characters = array_merge( array('------', ' ---- ', '----', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney );
$static_replacements = array_merge( array($em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace );
Now -- will appear as two small hyphens. If we want to insert a dash (—), we will need to type
four consecutive hyphens.
NOTE: Remember to do this after all Wordpress updates.