I am learning regex very much still so need to practice. I use gskinner's regex tool online and Sublime2. These are python regexp which is different from the JS/CS.
^(\s+) Indents
^(\s+)?\n Match the empty lines
(:markdown\n){1}(\s+\b.*)+ Markdown plus first paragraph
I need to figure out how to detect a change in indention though, like lookbehind? aka "zero-width assertions"
CoffeeScript does not allow for unquoted variable or key names that have a hyphen character - or colon :. But also, with unquoted names, there is the increased risk of collision with keywords.
Keywords
/(typeof)(:)/
'\1'\2Finds any word that is preceded by a white space and which has either a dot . or pound/dash/hash-sign # (once) but no white-space characters. Then it separates these by groups and adds quotes plus additional comma at the end (Coffeecup).
/(\b[a-zA-Z0-9]+)((\.|\#)[a-zA-Z0-9\-_]+){1,}\b/
\1 '\2',Jade has implicit div tags for any word that starts with #. Coffeecup doesn't have this convention so we place a 'div' in between anywhere a # is preceded by either the beginning of a line or a space.
(^|\s)(\#)
\1div \2Jade element attributes are encapsulated in between parentheses ( and ) after which the HTML node text follows without being surrounded by quotes. Coffeecup does not need encapsulation of attributes and has a closure which serves as the node text or, provides a function -> to nest the next tag. It is not possible to use the second to last attribute as a replacement for the closure to provide a node text (you can use a span or p for this and often better). Fortunately, attributes are already separated by , commas so we don't have to worry about those. Unfortunately, Jade has some flexible rules about multi-line attribute placement which also makes the use of comma's optional, or have the attribute post-fixed with commas and optionally start a new line right after the opening parenthesis (. For this reason, we can't just replace any occurrences of ( and ) but need to evaluate its context.