summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2022-06-14 17:37:01 +0200
committerMarc Vertes <mvertes@free.fr>2022-06-14 17:37:01 +0200
commit96f5dc439ef6f91ba50ae842d4e5cb86c92a3553 (patch)
tree521c3bafc245c623fee1dde274d37db97318b9db
parent6c3f8a99905545cea8e36434ec01455ad8ce355f (diff)
update
-rw-r--r--.i3status.conf3
-rwxr-xr-xbin/md2html193
2 files changed, 95 insertions, 101 deletions
diff --git a/.i3status.conf b/.i3status.conf
index 411a648..6cc7210 100644
--- a/.i3status.conf
+++ b/.i3status.conf
@@ -46,7 +46,8 @@ ethernet _first_ {
battery all {
last_full_capacity = true
integer_battery_capacity = true
- format = "%status %percentage %remaining"
+# format = "%status %percentage %remaining"
+ format = "%status %percentage %remaining %consumption"
status_chr = "⚡🔋"
status_bat = "🔋"
status_unk = "? UNK"
diff --git a/bin/md2html b/bin/md2html
index 35e1d72..7be4aaa 100755
--- a/bin/md2html
+++ b/bin/md2html
@@ -1,43 +1,42 @@
#!/usr/bin/awk -f
# md2html.awk
-# by: Jesus Galan (yiyus) <yiyu.jgl@gmail>, May 2009
# Usage:
# md2html file.md > file.html
# Options: -v esc=false to not escape html
-function newblock(nblock){
- if(text)
- print "<" block ">" text "</" block ">";
- text = "";
- block = nblock ? nblock : "p";
+function newblock(nblock) {
+ if (text)
+ print "<" block ">" text "</" block ">"
+ text = ""
+ block = nblock ? nblock : "p"
}
-function subinline(tgl, inl){
- while(match($0, tgl)){
+function subinline(tgl, inl) {
+ while (match($0, tgl)){
if (inline[ni] == inl)
- ni -= sub(tgl, "</" inl ">");
+ ni -= sub(tgl, "</" inl ">")
else if (sub(tgl, "<" inl ">"))
- inline[++ni] = inl;
+ inline[++ni] = inl
}
}
-function dolink(href, lnk){
+function dolink(href, lnk) {
# Undo escaped html in uris
- gsub(/&amp;/, "\\&", href);
- gsub(/&lt;/, "<", href);
- gsub(/&gt;/, ">", href);
+ gsub(/&amp;/, "\\&", href)
+ gsub(/&lt;/, "<", href)
+ gsub(/&gt;/, ">", href)
# & can be tricky, and not standard:
- gsub(/&/, "\\\\\\&", href);
- gsub(/&/, "\\\\\\&", lnk);
- return "<a href=\"" href "\">" lnk "</a>";
+ gsub(/&/, "\\\\\\&", href)
+ gsub(/&/, "\\\\\\&", lnk)
+ return "<a href=\"" href "\">" lnk "</a>"
}
BEGIN {
ni = 0; # inlines
nl = 0; # nested lists
- text = "";
- block = "p";
+ text = ""
+ block = "p"
}
# Escape html
@@ -49,128 +48,122 @@ esc != "false" {
# Horizontal rules (_ is not in markdown)
/^[ ]*([-*_] ?)+[ ]*$/ && text == "" {
- print "<hr>";
- next;
+ print "<hr>"
+ next
}
# Tables (not in markdown)
# Syntax:
# Right Align| Center Align |Left Align
/([ ]\|)|(\|[ ])/ {
- if(block != "table")
- newblock("table");
- nc = split($0, cells, "|");
- $0 = "<tr>\n";
- for(i = 1; i <= nc; i++){
- align = "left";
- if(sub(/^[ ]+/, "", cells[i])){
- if(sub(/[ ]+$/, "", cells[i]))
- align = "center";
+ if (block != "table")
+ newblock("table")
+ nc = split($0, cells, "|")
+ $0 = "<tr>\n"
+ for (i = 1; i <= nc; i++){
+ align = "left"
+ if (sub(/^[ ]+/, "", cells[i])){
+ if (sub(/[ ]+$/, "", cells[i]))
+ align = "center"
else
- align = "right";
+ align = "right"
}
- sub(/[ ]+$/,"", cells[i]);
- $0 = $0 "<td align=\"" align "\">" cells[i] "</td>\n";
+ sub(/[ ]+$/,"", cells[i])
+ $0 = $0 "<td align=\"" align "\">" cells[i] "</td>\n"
}
- $0 = $0 "</tr>";
+ $0 = $0 "</tr>"
}
# Ordered and unordered (possibly nested) lists
/^[ ]*([*+-]|(([0-9]+[\.-]?)+))[ ]/ {
- newblock("li");
- nnl = 1;
- while(match($0, /^[ ]/)){
- sub(/^[ ]/,"");
- nnl++;
+ newblock("li")
+ nnl = 1
+ while (match($0, /^[ ]/)){
+ sub(/^[ ]/,"")
+ nnl++
}
- while(nl > nnl)
- print "</" list[nl--] ">";
- while(nl < nnl){
- list[++nl] = "ol";
- if(match($0, /^[*+-]/))
- list[nl] = "ul";
- print "<" list[nl] ">";
+ while (nl > nnl)
+ print "</" list[nl--] ">"
+ while (nl < nnl){
+ list[++nl] = "ol"
+ if (match($0, /^[*+-]/))
+ list[nl] = "ul"
+ print "<" list[nl] ">"
}
- sub(/^([*+-]|(([0-9]+[\.-]?)+))[ ]/,"");
+ sub(/^([*+-]|(([0-9]+[\.-]?)+))[ ]/,"")
}
# Multi line list items
block == "li" {
- sub(/^( *)|( *)/,"");
+ sub(/^( *)|( *)/,"")
}
# Code blocks
/^( | )/ {
- if(block != "code")
- newblock("code");
- sub(/^( | )/, "");
- text = text $0 "\n";
- next;
+ if (block != "code")
+ newblock("code")
+ sub(/^( | )/, "")
+ text = text $0 "\n"
+ next
}
-# Paragraph
+# Paragraphs
/^$/ {
- newblock();
- while(nl > 0)
- print "</" list[nl--] ">";
+ newblock()
+ while (nl > 0)
+ print "</" list[nl--] ">"
}
-# Setex-style Headers
-# (Plus h3 with underscores.)
-/^=+$/ {
- block = "h" 1;
- next;
-}
-
-/^-+$/ {
- block = "h" 2;
- next;
+# Headers
+/^#/ {
+ newblock()
+ match($0, /#+/)
+ n = RLENGTH
+ if (n > 6)
+ n = 6
+ text = substr($0, RLENGTH + 1)
+ block = "h" n
+ next
}
-/^_+$/ {
- block = "h" 3;
- next;
+# Alternate headers (underlined)
+/^=+$/ {
+ block = "h" 1
+ next
}
-# Atx-style headers
-/^#/ {
- newblock();
- match($0, /#+/);
- n = RLENGTH;
- if(n > 6)
- n = 6;
- text = substr($0, RLENGTH + 1);
- block = "h" n;
- next;
+/^-+$/ {
+ block = "h" 2
+ next
}
-// {
+{
# Images
- while(match($0, /!\[[^\]]+\]\([^\)]+\)/)){
- split(substr($0, RSTART, RLENGTH), a, /(!\[)|\)|(\]\()/);
- sub(/!\[[^\]]+\]\([^\)]+\)/, "<img src=\"" a[3] "\" alt=\"" a[2] "\">");
+ while (match($0, /!\[[^\]]+\]\([^\)]+\)/)){
+ split(substr($0, RSTART, RLENGTH), a, /(!\[)|\)|(\]\()/)
+ sub(/!\[[^\]]+\]\([^\)]+\)/, "<img src=\"" a[3] "\" alt=\"" a[2] "\">")
}
# Links
- while(match($0, /\[[^\]]+\]\([^\)]+\)/)){
- split(substr($0, RSTART, RLENGTH), a, /[\[\)]|(\]\()/);
- sub(/\[[^\]]+\]\([^\)]+\)/, dolink(a[3], a[2]));
+ while (match($0, /\[[^\]]+\]\([^\)]+\)/)){
+ split(substr($0, RSTART, RLENGTH), a, /[\[\)]|(\]\()/)
+ sub(/\[[^\]]+\]\([^\)]+\)/, dolink(a[3], a[2]))
}
# Auto links (uri matching is poor)
- na = split($0, a, /(^\()|[ ]|([,\.\)]([ ]|$))/);
- for(i = 1; i <= na; i++)
- if(match(a[i], /^(((https?|ftp|file|news|irc):\/\/)|(mailto:)).+$/))
- sub(a[i], dolink(a[i], a[i]));
+ na = split($0, a, /(^\()|[ ]|([,\.\)]([ ]|$))/)
+ for (i = 1; i <= na; i++)
+ if (match(a[i], /^(((https?|ftp|file|news|irc):\/\/)|(mailto:)).+$/))
+ sub(a[i], dolink(a[i], a[i]))
# Inline
- subinline("(\\*\\*)|(__)", "strong");
- subinline("\\*", "em");
- subinline("`", "code");
- text = text (text ? " " : "") $0;
+ subinline("(\\*\\*)|(__)", "strong")
+ subinline("\\*", "em")
+ subinline("`", "code")
+ text = text (text ? " " : "") $0
}
END {
- while(ni > 0)
- text = text "</" inline[ni--] ">";
- newblock();
- while(nl > 0)
- print "</" list[nl--] ">";
+ while (ni > 0)
+ text = text "</" inline[ni--] ">"
+ newblock()
+ while (nl > 0)
+ print "</" list[nl--] ">"
}