2020-11-08 20:38:58 +00:00
|
|
|
#!/usr/bin/env awk -f
|
|
|
|
|
|
|
|
BEGIN { IGNORECASE=1; }
|
|
|
|
|
|
|
|
{ skip=0; }
|
|
|
|
|
2020-11-08 22:54:52 +00:00
|
|
|
/^#\+(BEGIN|END)_SRC ?/i { gsub(/#\+(BEGIN|END)_SRC ?/,"```"); }
|
|
|
|
/^#\+(BEGIN|END)_[^ ]* ?/i { gsub(/#\+(BEGIN|END)_([^ ]*) ?/,"______"); }
|
2020-11-08 20:38:58 +00:00
|
|
|
/^#\+TITLE: / { gsub(/^#[^:]*: /,"# "); }
|
2020-11-08 21:19:03 +00:00
|
|
|
/^ *:[a-zA-Z_0-9]*:/ { skip=1; }
|
2020-11-08 20:38:58 +00:00
|
|
|
/^\* / { gsub(/^\* /,"# "); }
|
|
|
|
/^\*\* / { gsub(/^\*\* /,"## "); }
|
|
|
|
/^\*\*\* / { gsub(/^\*\*\* /,"### "); }
|
|
|
|
|
|
|
|
/^#\+(macro|lang|language|options|startup):/ { skip=1; }
|
|
|
|
/{{{br}}}/ { gsub(/{{{br}}}/,""); }
|
|
|
|
/{{{pemail}}}/ { gsub(/{{{pemail}}}/,"yann@esposito.host"); }
|
|
|
|
/@@html:/ { htmlskip = 1; }
|
|
|
|
|
|
|
|
!skip && /^#\+([^:]*):/ {
|
|
|
|
x=$1;
|
|
|
|
gsub(/^#\+/,"",x);
|
|
|
|
x=tolower(x);
|
|
|
|
gsub(/^#\+([^:]*):/,"",$0);
|
|
|
|
$0=x" "$0;
|
|
|
|
}
|
|
|
|
/^- / { gsub(/^- /,"* "); }
|
|
|
|
!skip && !htmlskip{
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
/@@/ && !/@@html:/ { htmlskip = 0; }
|