KnitML update
Meg has suggested that, even though my active knitting project isn't actually a knitted object, I should blog about my progress.
KnitML 0.1 was released in February, and the project has since received 82 downloads! The basic sock pattern I wrote as a starting point now validates and renders successfully.
To give you an idea of what I've been doing, here's how you express knitting the cuff with 1x1 ribbing:
So the pattern ends up looking something like this:
Now let's say that you want to create a KnitML pattern, but the thought of writing out all of those angled brackets makes you want to puke. I'm working on something called a domain-specific language (DSL) for knitting patterns. It looks much more like an actual knitting pattern. It's still important to have the XML representation underneath, but in order to get there, it's nice to have a shorthand like this to make your life easier:
So that's what I've been working on. I hope that it's at least a little bit interesting to non-geeks at this point.
KnitML 0.1 was released in February, and the project has since received 82 downloads! The basic sock pattern I wrote as a starting point now validates and renders successfully.
To give you an idea of what I've been doing, here's how you express knitting the cuff with 1x1 ribbing:
<instruction id="cuff-round">The KnitML is essentially "test knit" by the computer before the pattern is printed. So, for instance, if there were an odd number of stitches on the needles when the computer got to this point, it would indicate that there is a problem with the pattern. An added bonus is that the computer puts in the row numbers as it goes along.
<row type="round">
<repeat until="end">
<knit>1</knit>
<purl>1</purl>
</repeat>
</row>
</instruction>
<repeat-instruction idref="cuff-round">
<until-measures unit="in">1.5</until-measures>
</repeat-instruction>
So the pattern ends up looking something like this:
Round 1: PurlNow if English isn't your first language, you can just as easily have the pattern render in Spanish. You set an option on the software and you get this instead:
Round 2: *k1, p1, repeat from * to end
Repeat round 2 until piece measures 1.5 in.
Vuelta 1: Todo del revesMany thanks to Cristina, by the way, for the Spanish translation files.
Vuelta 2: *1 p der, 1 p rev, repite desde * hasta el final
Repite vuelta 2 hasta que la pieza mida 1.5 in.
Now let's say that you want to create a KnitML pattern, but the thought of writing out all of those angled brackets makes you want to puke. I'm working on something called a domain-specific language (DSL) for knitting patterns. It looks much more like an actual knitting pattern. It's still important to have the XML representation underneath, but in order to get there, it's nice to have a shorthand like this to make your life easier:
round { repeatToEnd { p 1; k 2; p 1 } }The above expression actually produces KnitML that looks like this:
round { knitToEnd() }
<row type="round">This is currently implemented using a language called Groovy. It's quite a fun language to work with, and Meg could tell you that I've been rather obsessed with it of late.
<repeat until="end">
<purl>1</purl>
<knit>2</knit>
<purl>1</purl>
</repeat>
</row>
<row type="round">
<repeat until="end">
<knit />
</repeat>
</row>
So that's what I've been working on. I hope that it's at least a little bit interesting to non-geeks at this point.
Comments