Added checkboxparser to parse check list,

Modified the way css file works: now it isn't included in each html
file so we don't need to regenerate the whole wiki just for a small
change
This commit is contained in:
2024-02-26 19:22:11 +01:00
parent abe3ac33c0
commit a95ea69f32
5 changed files with 56 additions and 9 deletions

View File

@@ -97,6 +97,7 @@ return require('packer').startup(function(use)
template_path = '~/.config/vimwiki/templates/cybersecurity/',
template_default = 'default',
template_ext = 'html',
css_name = 'css/styles.css',
syntax = 'markdown',
ext = '.md',
custom_wiki2html = '~/.config/vimwiki/parse_wiki.py',

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env runhaskell
-- This simple filter that replaces the default checkboxes with cool ones from the
-- utf-8 charset, the checklist displayed still contains the marker, which can
-- avoided by adding the task-list class to the div containing the checklist in
-- the markdown. ex:
--
-- Example.md
-- :::{.task-list}
-- - [x] item1
-- - [ ] item2
-- - [ ] item3
-- - [ ] item4
-- :::
--
-- This list will be rendered without the marker
import Text.Pandoc.JSON
import Data.Text (pack, unpack)
import qualified Data.Text as T
main = toJSONFilter checkBoxParser
checkBoxParser :: Inline -> Inline
-- checkBoxParser (Str T.pack "\9746") = Str (pack "pippo")
checkBoxParser (Str text) | T.unpack text == "\9746" = Str (T.pack "\9989")
checkBoxParser (Str text) | T.unpack text == "\9744" = Str (T.pack "\11036\65039")
checkBoxParser x = x

View File

@@ -47,6 +47,7 @@ def convert(
command = [
"pandoc",
"--filter={}/.config/vimwiki/linkParser.hs".format(os.environ['HOME']),
"--filter={}/.config/vimwiki/checkBoxParser.hs".format(os.environ['HOME']),
"--section-divs",
"--template={}".format(template) if path.isfile(template) else "",
#"--variable=css={}".format(css_file) if path.isfile(css_file) else "",

View File

@@ -17,6 +17,7 @@ $if(description-meta)$
<meta name="description" content="$description-meta$" />
$endif$
<title>$if(title-prefix)$$title-prefix$ $endif$$pagetitle$</title>
<link rel="stylesheet" href="/css/styles.css" />
$for(css)$
<link rel="stylesheet" href="$css$" />
$endfor$
@@ -29,9 +30,6 @@ $if(mathjax)$
$endif$
$math$
$endif$
<style>
$styles.html()$
</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->

View File

@@ -1,5 +1,7 @@
img {
border-radius: .5rem;
margin: auto;
display: block;
}
code {
@@ -37,7 +39,7 @@ table {
width: auto;
}
th {
background-color: #269b20;
background-color: #00b34e;
color: #FFFFFF;
}
th, td {
@@ -76,10 +78,6 @@ tr:last-child td:last-child {
text-decoration: underline;
}
a[href]:after {
content: " (" attr(href) ")";
}
abbr[title]:after {
content: " (" attr(title) ")";
}
@@ -248,10 +246,32 @@ pre {
}
blockquote {
border-left: 3px solid #01ff70;
background-color: #333;
border-radius: 0 .5rem .5rem 0;
border-left: .3rem solid #01ff70;
padding-left: 1rem;
}
input[type='checkbox'] {
color: red;
pointer-events: none;
}
/* Remove marker from bullet list */
.task-list li::marker {
content: '';
color: #0f0f0f;
font-size: 1.2em;
}
.task-list ul {
margin-left: -1rem;
}
ul {
padding-left: 1.5rem;
}
/* Code highlighting*/
pre > code.sourceCode { white-space: pre; position: relative; }