\\1<\\/code>", "g", s)
- # Bold/italic (simple, non-nested)
+ # Bold / italic (simple)
s = gensub(/\*\*([^*]+)\*\*/, "\\1<\\/strong>", "g", s)
s = gensub(/\*([^*]+)\*/, "\\1<\\/em>", "g", s)
# Autolink http(s)
@@ -72,139 +68,82 @@ function linkify(s, before,after){
return s
}
-# Emit paragraph buffer if needed
-function flush_p(){
- if(pbuf!=""){
- printf("%s
\n", pbuf);
- pbuf="";
- }
-}
+function flush_p(){ if(pbuf!=""){ printf("%s
\n", pbuf); pbuf="" } }
+function close_lists(){ if(in_ul){ print ""; in_ul=0 } if(in_ol){ print ""; in_ol=0 } }
+function close_blockquote(){ if(in_blockquote){ print ""; in_blockquote=0 } }
-# Close list/blockquote contexts
-function close_lists(){
- if(in_ul){ print ""; in_ul=0 }
- if(in_ol){ print ""; in_ol=0 }
-}
-function close_blockquote(){
- if(in_blockquote){ print ""; in_blockquote=0 }
-}
-
-# Table helpers
-function table_open_fn(){
- if(!table_open){ print ""; table_open=1 }
-}
-function table_close_fn(){
- if(table_open){ print "
"; table_open=0 }
- in_table=0
-}
-function split_cells(line, arr,n,i,cell){
- # strip leading/trailing |
+function table_close_fn(){ if(table_open){ print ""; table_open=0 } in_table=0 }
+function split_cells(line, n,i){
sub(/^ *\|/,"",line); sub(/\| *$/,"",line);
- n=split(line, arr, /\|/);
- for(i=1;i<=n;i++){
- gsub(/^ +| +$/,"",arr[i]); # trim
- arr[i]=arr[i];
- }
+ n=split(line, C, /\|/);
+ for(i=1;i<=n;i++){ gsub(/^ +| +$/,"",C[i]) }
return n
}
{
raw=$0
- # Track last nonblank for table header detection
if(raw ~ /[^[:space:]]/){ last_nonblank=raw }
- # Handle fenced code
- if(!in_code && raw ~ /^```/){
- flush_p(); close_lists(); close_blockquote();
- print ""; in_code=1; next
- }
+ # Fenced code
+ if(!in_code && raw ~ /^```/){ flush_p(); close_lists(); close_blockquote(); print ""; in_code=1; next }
if(in_code){
if(raw ~ /^```/){ print "
"; in_code=0; next }
print htmlesc(raw); next
}
- # Blank line: end paragraphs/lists/quotes; not tables
+ # Blank line
if(raw ~ /^[[:space:]]*$/){
if(in_table==0){ flush_p(); close_lists(); close_blockquote() }
next
}
- # Horizontal rule
- if(raw ~ /^ *(-{3,}|\*{3,}|_{3,}) *$/){
- flush_p(); close_lists(); close_blockquote();
- print "
"; next
- }
+ # HR
+ if(raw ~ /^ *(-{3,}|\*{3,}|_{3,}) *$/){ flush_p(); close_lists(); close_blockquote(); print "
"; next }
- # Table separator row => open table, emit header from last_nonblank
+ # Table separator row -> open table with the previous header line
if(raw ~ /^ *\|? *:?-{3,}:? *(?:\| *:?-{3,}:? *)+\|? *$/){
- # last_nonblank is header
hdr=last_nonblank
- # Parse header into
- split_cells(hdr, H, nH)
- print ""
- for(i=1;i<=nH;i++){ printf("%s ", linkify(htmlesc(H[i]))) }
- print " "
- in_table=1; table_open=1
- next
+ split_cells(hdr); print "";
+ for(i=1;i in C;i++){ printf("%s ", linkify(htmlesc(C[i]))) }
+ print " "; in_table=1; table_open=1; next
}
-
- # Inside table: any row with at least one pipe (and not a fence)
if(in_table && raw ~ /\|/){
- split_cells(raw, C, nC)
- printf("")
- for(i=1;i<=nC;i++){ printf("%s ", linkify(htmlesc(C[i]))) }
- print " "
- next
- }
- # Exiting table block if we hit a non-pipe line
- if(in_table){
- table_close_fn()
+ split_cells(raw); printf("");
+ for(i=1;i in C;i++){ printf("%s ", linkify(htmlesc(C[i]))) }
+ print " "; next
}
+ if(in_table){ table_close_fn() }
# Blockquotes
if(raw ~ /^ *> */){
flush_p(); close_lists();
if(!in_blockquote){ print ""; in_blockquote=1 }
- gsub(/^ *> */,"",raw)
- print "" linkify(htmlesc(raw)) "
"
- next
- }else{
- if(in_blockquote && raw !~ /^ *> */){ close_blockquote() }
- }
+ gsub(/^ *> */,"",raw); print "" linkify(htmlesc(raw)) "
"; next
+ } else if(in_blockquote){ close_blockquote() }
# Headings
if(raw ~ /^#{1,6} /){
flush_p(); close_lists(); close_blockquote();
- m=match(raw,/^#{1,6}/); level=RLENGTH
- text=substr(raw, level+2)
- printf("%s \n", level, linkify(htmlesc(text)), level)
- next
+ m=match(raw,/^#{1,6}/); level=RLENGTH; text=substr(raw, level+2);
+ printf("%s \n", level, linkify(htmlesc(text)), level); next
}
# Lists
if(raw ~ /^ *([-*]) +/){
- flush_p()
- if(!in_ul){ print ""; in_ul=1 }
- item=raw; sub(/^ *[-*] +/,"",item)
- print "- " linkify(htmlesc(item)) "
"
- next
+ flush_p(); if(!in_ul){ print ""; in_ul=1 }
+ item=raw; sub(/^ *[-*] +/,"",item); print "- " linkify(htmlesc(item)) "
"; next
}
if(raw ~ /^ *[0-9]+\. +/){
- flush_p()
- if(!in_ol){ print ""; in_ol=1 }
- item=raw; sub(/^ *[0-9]+\. +/,"",item)
- print "- " linkify(htmlesc(item)) "
"
- next
+ flush_p(); if(!in_ol){ print ""; in_ol=1 }
+ item=raw; sub(/^ *[0-9]+\. +/,"",item); print "- " linkify(htmlesc(item)) "
"; next
}
- # If we switch list types or leave lists
if(in_ul && raw !~ /^ *([-*]) +/ && raw !~ /^[[:space:]]*$/){ close_lists() }
if(in_ol && raw !~ /^ *[0-9]+\. +/ && raw !~ /^[[:space:]]*$/){ close_lists() }
- # Default: paragraph (accumulate soft-wrap into one )
+ # Paragraph accumulation (soft-wrap)
line = linkify(htmlesc(raw))
if(pbuf==""){ pbuf=line } else { pbuf=pbuf " " line }
}
-
END{
if(in_code){ print "" }
if(in_table){ table_close_fn() }
diff --git a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh
index 3405fe1..5be2be0 100755
--- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh
+++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh
@@ -275,14 +275,7 @@ __update_conf_files() {
# __replace "" "" "$CONF_DIR/nginx.conf"
# replace variables recursively
# __find_replace "" "" "$CONF_DIR"
- if [ -f "$WWW_ROOT_DIR/index.html" ]; then
- sed -i 's|REPLACE_ONION_WWW_DIR|'$WWW_ROOT_DIR'|g' "/data/htdocs/www/index.html"
- [ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "$WWW_ROOT_DIR/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "$WWW_ROOT_DIR/index.html"
- fi
- if [ -f "/data/htdocs/www/index.html" ]; then
- sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/www|g' "/data/htdocs/www/index.html"
- [ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "/data/htdocs/www/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "/data/htdocs/www/index.html"
- fi
+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# define actions
while :; do
@@ -326,6 +319,14 @@ __update_conf_files() {
echo "Created $onion_site.onion in /data/htdocs/onions/$onion_site"
done
fi
+ if [ -f "$WWW_ROOT_DIR/index.html" ]; then
+ sed -i 's|REPLACE_ONION_WWW_DIR|'$WWW_ROOT_DIR'|g' "/data/htdocs/www/index.html"
+ [ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "$WWW_ROOT_DIR/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "$WWW_ROOT_DIR/index.html"
+ fi
+ if [ -f "/data/htdocs/www/index.html" ]; then
+ sed -i 's|REPLACE_ONION_WWW_DIR|/data/htdocs/www|g' "/data/htdocs/www/index.html"
+ [ -n "$default_host" ] && sed -i 's|REPLACE_DEFAULT_TOR_ADDRESS|'$default_host.onion'|g' "/data/htdocs/www/index.html" || sed -i '/REPLACE_DEFAULT_TOR_ADDRESS/d' "/data/htdocs/www/index.html"
+ fi
# allow custom functions
if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi
# exit function