her.esy.fun/engine/org2gemini_step1.sh

37 lines
843 B
Bash
Raw Normal View History

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-22 09:31:04 +00:00
2021-06-21 12:05:31 +00:00
/^#\+(macro|lang|language|options|startup|html_head|html_head_extra):/ { skip=1; }
2020-11-22 09:31:04 +00:00
/{{{br}}}/ { gsub(/{{{br}}}/,""); }
/{{{pemail}}}/ { gsub(/{{{pemail}}}/,"yann@esposito.host"); }
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; }
2021-05-02 09:17:38 +00:00
# title
2020-11-08 20:38:58 +00:00
/^\* / { gsub(/^\* /,"# "); }
/^\*\* / { gsub(/^\*\* /,"## "); }
/^\*\*\* / { gsub(/^\*\*\* /,"### "); }
/@@html:/ { htmlskip = 1; }
!skip && /^#\+([^:]*):/ {
x=$1;
gsub(/^#\+/,"",x);
x=tolower(x);
gsub(/^#\+([^:]*):/,"",$0);
$0=x" "$0;
}
/^- / { gsub(/^- /,"* "); }
2021-05-02 09:17:38 +00:00
!skip && !htmlskip{
2020-11-08 20:38:58 +00:00
print;
}
/@@/ && !/@@html:/ { htmlskip = 0; }
2020-11-22 09:31:04 +00:00
/@@$/ { htmlskip = 0; }