commit b2d46c4a3db4b73daa5958f3c2f5590cfdb60be3
parent aa8f2b0e96fadea93df2265f6d18693e600d31a2
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Wed,  2 Feb 2022 21:17:35 +0100

Change checkboxes for VimWiki HTML pages

Diffstat:
A.local/share/vimwiki/assets/README | 2++
A.local/share/vimwiki/assets/box-0.svg | 1+
A.local/share/vimwiki/assets/box-1.svg | 1+
A.local/share/vimwiki/assets/box-2.svg | 1+
A.local/share/vimwiki/assets/box-3.svg | 1+
A.local/share/vimwiki/assets/box-4.svg | 1+
M.local/share/vimwiki/template.html | 25+++++++++++++++++++++++++
M.local/share/vimwiki/wiki2html.py | 7+++++--
8 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/.local/share/vimwiki/assets/README b/.local/share/vimwiki/assets/README @@ -0,0 +1,2 @@ +This are the original SVGs for the TODOs checkboxes. They have been URL-encoded +and put inside the template.html CSS as data URLs. diff --git a/.local/share/vimwiki/assets/box-0.svg b/.local/share/vimwiki/assets/box-0.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 448"><path fill="#226699" d="M 400,0 H 48 C 21.5,0 0,21.5 0,48 v 352 c 0,26.5 21.5,48 48,48 h 352 c 26.5,0 48,-21.5 48,-48 V 48 C 448,21.5 426.5,0 400,0 Z m -6,400 H 54 c -3.3,0 -6,-2.7 -6,-6 V 54 c 0,-3.3 2.7,-6 6,-6 h 340 c 3.3,0 6,2.7 6,6 v 340 c 0,3.3 -2.7,6 -6,6 z" /></svg> diff --git a/.local/share/vimwiki/assets/box-1.svg b/.local/share/vimwiki/assets/box-1.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 448"><path fill="#226699" d="M 400,0 H 48 C 21.5,0 0,21.5 0,48 v 352 c 0,26.5 21.5,48 48,48 h 352 c 26.5,0 48,-21.5 48,-48 V 48 C 448,21.5 426.5,0 400,0 Z m -6,400 H 54 c -3.3,0 -6,-2.7 -6,-6 V 54 c 0,-3.3 2.7,-6 6,-6 h 340 c 3.3,0 6,2.7 6,6 v 340 c 0,3.3 -2.7,6 -6,6 z" /><rect fill="#226699" width="400" height="112" x="24" y="312" /></svg> diff --git a/.local/share/vimwiki/assets/box-2.svg b/.local/share/vimwiki/assets/box-2.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 448"><path fill="#226699" d="M 400,0 H 48 C 21.5,0 0,21.5 0,48 v 352 c 0,26.5 21.5,48 48,48 h 352 c 26.5,0 48,-21.5 48,-48 V 48 C 448,21.5 426.5,0 400,0 Z m -6,400 H 54 c -3.3,0 -6,-2.7 -6,-6 V 54 c 0,-3.3 2.7,-6 6,-6 h 340 c 3.3,0 6,2.7 6,6 v 340 c 0,3.3 -2.7,6 -6,6 z" /><rect fill="#226699" width="400" height="200" x="24" y="224" /></svg> diff --git a/.local/share/vimwiki/assets/box-3.svg b/.local/share/vimwiki/assets/box-3.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 448"><path fill="#226699" d="M 400,0 H 48 C 21.5,0 0,21.5 0,48 v 352 c 0,26.5 21.5,48 48,48 h 352 c 26.5,0 48,-21.5 48,-48 V 48 C 448,21.5 426.5,0 400,0 Z m -6,400 H 54 c -3.3,0 -6,-2.7 -6,-6 V 54 c 0,-3.3 2.7,-6 6,-6 h 340 c 3.3,0 6,2.7 6,6 v 340 c 0,3.3 -2.7,6 -6,6 z" /><rect fill="#226699" width="400" height="288" x="24" y="136" /></svg> diff --git a/.local/share/vimwiki/assets/box-4.svg b/.local/share/vimwiki/assets/box-4.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 448"><path fill="#226699" d="M 400,448 H 48 C 21.49,448 0,426.51 0,400 V 48 C 0,21.49 21.49,0 48,0 h 352 c 26.51,0 48,21.49 48,48 v 352 c 0,26.51 -21.49,48 -48,48 z m -204.686,-98.059 184,-184 c 6.248,-6.248 6.248,-16.379 0,-22.627 l -22.627,-22.627 c -6.248,-6.248 -16.379,-6.249 -22.628,0 L 184,270.745 113.941,200.686 c -6.248,-6.248 -16.379,-6.248 -22.628,0 l -22.627,22.627 c -6.248,6.248 -6.248,16.379 0,22.627 l 104,104 c 6.249,6.25 16.379,6.25 22.628,10e-4 z" /></svg> diff --git a/.local/share/vimwiki/template.html b/.local/share/vimwiki/template.html @@ -85,6 +85,31 @@ a.nav:hover { margin-right: 0px; color: #555; } +img.checkbox-0 { + content: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20448%20448%22%3E%3Cpath%20fill%3D%22%23226699%22%20d%3D%22M%20400%2C0%20H%2048%20C%2021.5%2C0%200%2C21.5%200%2C48%20v%20352%20c%200%2C26.5%2021.5%2C48%2048%2C48%20h%20352%20c%2026.5%2C0%2048%2C-21.5%2048%2C-48%20V%2048%20C%20448%2C21.5%20426.5%2C0%20400%2C0%20Z%20m%20-6%2C400%20H%2054%20c%20-3.3%2C0%20-6%2C-2.7%20-6%2C-6%20V%2054%20c%200%2C-3.3%202.7%2C-6%206%2C-6%20h%20340%20c%203.3%2C0%206%2C2.7%206%2C6%20v%20340%20c%200%2C3.3%20-2.7%2C6%20-6%2C6%20z%22%20%2F%3E%3C%2Fsvg%3E); + max-height: 1em; + max-width: 1em; +} +img.checkbox-1 { + content: url(data:image/svg+xml,%0A%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20448%20448%22%3E%3Cpath%20fill%3D%22%23226699%22%20d%3D%22M%20400%2C0%20H%2048%20C%2021.5%2C0%200%2C21.5%200%2C48%20v%20352%20c%200%2C26.5%2021.5%2C48%2048%2C48%20h%20352%20c%2026.5%2C0%2048%2C-21.5%2048%2C-48%20V%2048%20C%20448%2C21.5%20426.5%2C0%20400%2C0%20Z%20m%20-6%2C400%20H%2054%20c%20-3.3%2C0%20-6%2C-2.7%20-6%2C-6%20V%2054%20c%200%2C-3.3%202.7%2C-6%206%2C-6%20h%20340%20c%203.3%2C0%206%2C2.7%206%2C6%20v%20340%20c%200%2C3.3%20-2.7%2C6%20-6%2C6%20z%22%20%2F%3E%3Crect%20fill%3D%22%23226699%22%20width%3D%22400%22%20height%3D%22112%22%20x%3D%2224%22%20y%3D%22312%22%20%2F%3E%3C%2Fsvg%3E); + max-height: 1em; + max-width: 1em; +} +img.checkbox-2 { + content: url(data:image/svg+xml,%0A%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20448%20448%22%3E%3Cpath%20fill%3D%22%23226699%22%20d%3D%22M%20400%2C0%20H%2048%20C%2021.5%2C0%200%2C21.5%200%2C48%20v%20352%20c%200%2C26.5%2021.5%2C48%2048%2C48%20h%20352%20c%2026.5%2C0%2048%2C-21.5%2048%2C-48%20V%2048%20C%20448%2C21.5%20426.5%2C0%20400%2C0%20Z%20m%20-6%2C400%20H%2054%20c%20-3.3%2C0%20-6%2C-2.7%20-6%2C-6%20V%2054%20c%200%2C-3.3%202.7%2C-6%206%2C-6%20h%20340%20c%203.3%2C0%206%2C2.7%206%2C6%20v%20340%20c%200%2C3.3%20-2.7%2C6%20-6%2C6%20z%22%20%2F%3E%3Crect%20fill%3D%22%23226699%22%20width%3D%22400%22%20height%3D%22200%22%20x%3D%2224%22%20y%3D%22224%22%20%2F%3E%3C%2Fsvg%3E); + max-height: 1em; + max-width: 1em; +} +img.checkbox-3 { + content: url(data:image/svg+xml,%0A%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20448%20448%22%3E%3Cpath%20fill%3D%22%23226699%22%20d%3D%22M%20400%2C0%20H%2048%20C%2021.5%2C0%200%2C21.5%200%2C48%20v%20352%20c%200%2C26.5%2021.5%2C48%2048%2C48%20h%20352%20c%2026.5%2C0%2048%2C-21.5%2048%2C-48%20V%2048%20C%20448%2C21.5%20426.5%2C0%20400%2C0%20Z%20m%20-6%2C400%20H%2054%20c%20-3.3%2C0%20-6%2C-2.7%20-6%2C-6%20V%2054%20c%200%2C-3.3%202.7%2C-6%206%2C-6%20h%20340%20c%203.3%2C0%206%2C2.7%206%2C6%20v%20340%20c%200%2C3.3%20-2.7%2C6%20-6%2C6%20z%22%20%2F%3E%3Crect%20fill%3D%22%23226699%22%20width%3D%22400%22%20height%3D%22288%22%20x%3D%2224%22%20y%3D%22136%22%20%2F%3E%3C%2Fsvg%3E); + max-height: 1em; + max-width: 1em; +} +img.checkbox-4 { + content: url(data:image/svg+xml,%0A%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20448%20448%22%3E%3Cpath%20fill%3D%22%23226699%22%20d%3D%22M%20400%2C448%20H%2048%20C%2021.49%2C448%200%2C426.51%200%2C400%20V%2048%20C%200%2C21.49%2021.49%2C0%2048%2C0%20h%20352%20c%2026.51%2C0%2048%2C21.49%2048%2C48%20v%20352%20c%200%2C26.51%20-21.49%2C48%20-48%2C48%20z%20m%20-204.686%2C-98.059%20184%2C-184%20c%206.248%2C-6.248%206.248%2C-16.379%200%2C-22.627%20l%20-22.627%2C-22.627%20c%20-6.248%2C-6.248%20-16.379%2C-6.249%20-22.628%2C0%20L%20184%2C270.745%20113.941%2C200.686%20c%20-6.248%2C-6.248%20-16.379%2C-6.248%20-22.628%2C0%20l%20-22.627%2C22.627%20c%20-6.248%2C6.248%20-6.248%2C16.379%200%2C22.627%20l%20104%2C104%20c%206.249%2C6.25%2016.379%2C6.25%2022.628%2C10e-4%20z%22%20%2F%3E%3C%2Fsvg%3E); + max-height: 1em; + max-width: 1em; +} </style> </head> <body> diff --git a/.local/share/vimwiki/wiki2html.py b/.local/share/vimwiki/wiki2html.py @@ -99,8 +99,11 @@ def wiki_to_html(input_file, output_file, template_file, root_path, wiki_path, c # format links for HTML text = re.sub('\[([^]]+)\]\(([^)#]*)(?:#([^)]*))?\)', lambda m: href_to_html(m, wiki_path, root_path), text) # add support for TODOs - text = re.sub('^([ \t]*- )\[[ .oO]\] ', lambda m : m.group(1) + '<input type="checkbox" disabled> ', text, flags=re.MULTILINE) - text = re.sub('^([ \t]*- )\[X\] ', lambda m : m.group(1) + '<input type="checkbox" checked disabled> ', text, flags=re.MULTILINE) + text = re.sub('^([ \t]*- )\[ \] ', lambda m : m.group(1) + '<img class="checkbox-0"> ', text, flags=re.MULTILINE) + text = re.sub('^([ \t]*- )\[\.\] ', lambda m : m.group(1) + '<img class="checkbox-1"> ', text, flags=re.MULTILINE) + text = re.sub('^([ \t]*- )\[o\] ', lambda m : m.group(1) + '<img class="checkbox-2"> ', text, flags=re.MULTILINE) + text = re.sub('^([ \t]*- )\[O\] ', lambda m : m.group(1) + '<img class="checkbox-3"> ', text, flags=re.MULTILINE) + text = re.sub('^([ \t]*- )\[X\] ', lambda m : m.group(1) + '<img class="checkbox-4"> ', text, flags=re.MULTILINE) params['metadata'] = '' if params['category'] != categories[0]: