ometa xhtmlParser { name = letterOrDigit+:ls -> ls.join(''), unitag = '<' spaces name:n attribute*:a spaces '/'* '>' -> [n, a], tag = '<' spaces name:n attribute*:a spaces '>' html*:c '<' '/' seq(n) spaces '>' -> [n, a, c], html = text:t -> ['', t] | tag:t -> [t[0], t[1], t[2]] | unitag:t -> [t[0], t[1]], text = (~'<' anything)+:t -> t.join(''), attribute = spaces name:k spaces '=' spaces (qstring | name):v -> [k, v], qstring = ('"' | '\''):q (~exactly(q) anything)*:xs exactly(q) -> {xs.join('')} } txt="

this is the \ \ first \ attempt.\
I will be ok.

" tree=xhtmlParser.matchAll(txt,'html') [p, [], [[, this is the ], [b, [[sql, test]], [[, first ], [script, [], [[, test ]]], [, ]]], [, attempt. ], [br, [[sql, test 2]]], [, I will be ok. ]]] ometa getSql { sqlScript = [ :node [[~'sql' anything]* ['sql' :sql] anything*] [anything* ['script' anything [['' :script]]] anything ]] -> [sql, script], sqlOnly = [ :node [[~'sql' anything]* ['sql' :sql] anything*] anything* ] -> [sql, ''], tags = (sqlScript | sqlOnly | [anything:t anything tags])* -> t } getSql.match(tree[0],'tags') p ometa Tst { t = [ anything:a [[~11 anything anything]* [11 2]:b anything*] anything*] -> [a,b] } Tst.match([1,[[10,1],[11,2],[12,3]],[]],'t') 1 tree