<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jalf.dk &#187; formatting</title>
	<atom:link href="http://jalf.dk/blog/tag/formatting/feed/" rel="self" type="application/rss+xml" />
	<link>http://jalf.dk/blog</link>
	<description>Musings and thoughts on programming and other geeky stuff</description>
	<lastBuildDate>Mon, 16 Aug 2010 00:29:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Markdown and web typography</title>
		<link>http://jalf.dk/blog/2009/07/markdown-and-web-typography/</link>
		<comments>http://jalf.dk/blog/2009/07/markdown-and-web-typography/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 01:11:14 +0000</pubDate>
		<dc:creator>jalf</dc:creator>
				<category><![CDATA[Meta]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[web-design]]></category>

		<guid isPermaLink="false">http://jalf.dk/blog/?p=33</guid>
		<description><![CDATA[As a general rule, I swore years ago to stay as far away from web design and web development as at all possible. I still believe that this is one of the fundamental rules of happiness, and I haven’t regretted it, but for once, I was actually impressed (rather than depressed, which is what web [...]]]></description>
			<content:encoded><![CDATA[<p>As a general rule, I swore years ago to stay as far away from web design and web development as at all possible. I still believe that this is one of the fundamental rules of happiness, and I haven’t regretted it, but for once, I was actually <em>impressed</em> (rather than <em>de</em>pressed, which is what web development usually makes me feel like) with a few pieces of web design, and so I decided to make an exception and talk about it for a moment.</p>

<p>After launching this blog earlier today, I spent a bit of time researching how to get a more intuitive syntax for formatting my posts. I’m not really a fan of “rich text” text editors like the one WordPress uses by default (luckily it can be disabled). It offers limited control, is awkward to use, and just doesn’t lend itself to well-formatted posts.</p>

<p>So I decided to look for alternatives.</p>

<p><span id="more-33"></span> 
One source of inspiration is obviously LaTeX, which just does a ton of formatting automatically — converting quotes and adjusting spacing, hyphenation rules and a bunch of other fancy features. It also automatically converts multiple dashes to their typographic equivalents — a single dash is just rendered as a minus, two of them (<code>--</code>) as an en-dash, and three (<code>---</code>) as an em-dash.</p>

<p>I’ve also been very impressed with the formatting syntax used on <a href="http://stackoverflow.com">StackOverflow.com</a> for its simplicity and ease of use, and I happen to know they use Markdown to achieve it.</p>

<p>So those were things I went looking for in the WordPress plugin jungle, and those are pretty much what I came back with.</p>

<p>The <a href="http://wordpress.org/extend/plugins/wp-typography/">wp-typography</a> plugin takes care of much of the general typographic formatting, including hyphenation, converting single and double quotes, and even guessing at the correct type of dashes (so a <code>-</code> between words is rendered as an em-dash, exactly as it should be).</p>

<p>And the <a href="http://michelf.com/projects/php-markdown/">PHP Markdown Extra</a> plugin did the rest, giving me control over the formatting. With the Markdown plugin, I can format text freely without having to mess around with buttons above the editor textbox, and without having to use the “Visual” view which I’ve never trusted.</p>

<p>Instead, *text surrounded by asterisks* is automatically <em>emphasised</em> and  **double asterisks** becomes <strong>bolded</strong>.</p>

<p>Block quotes are written the way email replies typically did it: Starting each line with a <code>&gt;</code>, so this:</p>

<p>&gt; Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna<br />
&gt; aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex<br />
&gt; ea commodo consequat</p>

<p>ends up looking like this:</p>

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
  aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex 
  ea commodo consequat</p>
</blockquote>

<p>Since I’m likely to end up posting quite a bit of code snippets here, it’s worth mentioning the lovely simple syntax for that as well. Inline code is simply surrounded by backticks (‘), so ‘sqrt(42.0f);‘ ends up looking like this: <code>sqrt(42.0f);</code>.</p>

<p>Block code can be done either by starting and ending the block with a line with three tilde characters:</p>

<pre><code>~~~  
int foo() {  
  return 42;  
}  
~~~  
</code></pre>

<p>Or by starting each line with 4 or more spaces:</p>

<pre><code>    int foo() {  
      return 42;  
    }  
</code></pre>

<p>and ends up looking like this:</p>

<pre><code>int foo() {
  return 42;
}
</code></pre>

<p>Lists can be created just by starting each line with a dash:</p>

<p>- a<br />
– b<br />
– c</p>

<p>Will look like:</p>

<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>

<p>And links can be created like this:</p>

<pre><code>[this is a link](http://google.com)
</code></pre>

<p>and the result: <a href="http://google.com">this is a link</a></p>

<p>Horizontal rules can be placed just by writing three asterisks on a line by themselves:</p>

<p>***</p>

<p>ends up looking like</p>

<hr />

<p>The overall effect is quite simply that the raw unformatted text still looks perfectly readable. It looks much like what you’d see in ASCII-only emails. And that I can format my posts easily and the end result actually looks nice!</p>

<p>If you see any badly formatted text on this site, you can now rest safe in the knowledge that it’s just me being bad at typography and layout. It’s my fault, and mine alone. The WordPress WYSIWYG editor is no longer an issue.</p>

<p>So a big thank you to the developers of those two plugins for making my blog posts look a hell of a lot nicer than they would if it’d been left to WordPress alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://jalf.dk/blog/2009/07/markdown-and-web-typography/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
