Change R (in progress)
This commit is contained in:
parent
7bf4958b38
commit
fa0b5565c4
51
R
51
R
|
@ -1 +1,50 @@
|
|||
!/^<.*>$/{$0="<P>"$0}//
|
||||
# -*- awk -*-
|
||||
|
||||
BEGIN {
|
||||
FS="\n"; RS=""
|
||||
i=0
|
||||
_end = "__END__"
|
||||
_el=" el "; _defel="p"
|
||||
print ". hell/hell"
|
||||
}
|
||||
|
||||
function start(el) {
|
||||
split(el, el_a, " ")
|
||||
lvl[++i] = (el ? el_a[1] : _defel)
|
||||
return "$(<<" _end i lvl[i] _el lvl[i] "\n"
|
||||
}
|
||||
|
||||
function end() {
|
||||
return "\n" _end i lvl[i--] "\n)"
|
||||
}
|
||||
|
||||
function wrap(par) {
|
||||
if (par !~ /^<.*>$/)
|
||||
return start() par end()
|
||||
else
|
||||
return par
|
||||
}
|
||||
|
||||
/^@[^()]/ {
|
||||
$1 = start(substr($1, 2))
|
||||
sub(/\n?$/, end())
|
||||
print
|
||||
next
|
||||
}
|
||||
|
||||
/^@\(/ {
|
||||
print start(substr($1, 3))
|
||||
$1=""; $0=$0
|
||||
}
|
||||
|
||||
/@\)$/ {
|
||||
nf=$NF; NF--; $0=$0; print
|
||||
if ($0) {
|
||||
print wrap($0)
|
||||
print substr(nf, 0, length(nf)-2) end()
|
||||
} else
|
||||
print end()
|
||||
next
|
||||
}
|
||||
|
||||
{ print wrap($0); }
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
here is a paragraph.
|
||||
with two lines.
|
||||
|
||||
here's another with one
|
||||
|
||||
<ul>
|
||||
<li>one
|
||||
</ul>
|
||||
|
||||
@blockquote
|
||||
here's a blockquote.
|
||||
|
||||
@(blockquote class=long
|
||||
here's another
|
||||
|
||||
with 2 paragrapsh.
|
||||
@)
|
||||
|
||||
@(div class=nested
|
||||
here's a nested div
|
||||
|
||||
@(div class=inside
|
||||
with something inside
|
||||
|
||||
@)
|
||||
|
||||
@blockquote
|
||||
and a blockquote
|
||||
|
||||
@)
|
||||
|
||||
okay.
|
Loading…
Reference in New Issue