Markdown in Posts

This is actually my second post, I deleted the first post because I changed the default markup from HTML to Markdown. This means I can easily add nicely syntax highlighted code to my posts. Which will come in handy since the blog will largely be about code.

To prove it, here is a Mandlebrot Set generator in Moya Code:

<?xml version="1.0"?>
<moya xmlns="http://moyaproject.com">
    <macro docname="main">
        <!-- <breakpoint /> -->
        <echo>Generates an ASCII mandelbrot set</echo>
        <echo>Run with "moya run mandel.xml -e mandel"</echo>
    </macro>
    <macro docname="mandel">
        <let xsize="80" ysize="20" max_iteration="50"/>
        <let-str chars=" .,~:;+*%@##"/>
        <let xrange="0...xsize" yrange="0...ysize" />
        <for src="yrange" dst="pixy">
            <let y0="(pixy/ysize) * 2 - 1" row="''" />
            <for src="xrange" dst="pixx">
                <let x0="(pixx/xsize) * 3 - 2"
                     x="0" y="0" dst="0" iteration="0"/>
                <while test="(x*x + y*y) lt 4 and iteration lt max_iteration">
                    <let xtemp="x*x - y*y + x0"
                         y="2*x*y + y0"
                         x="xtemp"
                         iteration="iteration + 1"/>
                </while>
                <let row="row + chars[iteration % 10]" />
            </for>
            <echo>${row}</echo>
        </for>
    </macro>
</moya>

I've used this code as a benchmark for Moya since it was capable of running such code. It is a good benchmark because it represents the worst case performance for Moya Code.

To try it out, save the above code as mandel.xml and run the following:

moya run mandel.xml -e mandel

Add the --breakpoint switch if you want to step through the code.

read more…