Start work on export options
I have started an html export. So far a toc is generated
This commit is contained in:
parent
a9cdb7dfe9
commit
4c891efdce
2 changed files with 91 additions and 33 deletions
36
inc/to-html
Normal file
36
inc/to-html
Normal file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This file is responsible for generating an html structure of documents
|
||||
# All md files will be converted to html
|
||||
# Everything else will be copied exactly
|
||||
|
||||
# The table of contents will be a nested ul structure
|
||||
# The top level will be the tags, under each tag there will be a list of documents that are tagged with that tag
|
||||
# This will result in doucuments being listed multiple times, once for each tag they are in
|
||||
generate-html-toc(){
|
||||
echo "<nav><ul>"
|
||||
# Loop through each tag
|
||||
listTags --noheader | while read item; do
|
||||
local tag="$(echo "$item" | awk -F ' +' '{print $1}')"
|
||||
local count="$(echo "$item" | awk -F ' +' '{print $2}')"
|
||||
echo "<li>"
|
||||
echo "$tag ($count)"
|
||||
echo "<ul>"
|
||||
echo "SELECT items.filename,items.title
|
||||
FROM items LEFT JOIN links ON items.id = links.itemID
|
||||
LEFT JOIN tags ON links.tagID = tags.id
|
||||
WHERE tags.name = '$(safeSQL "$tag")'
|
||||
GROUP BY items.id;" |
|
||||
sqlite3 "${sqliteFile}" |
|
||||
awk -F '|' '{sub(/\.md/,".html",$1);print "<li><a href=\"" $1 "\">" $2 "</a></li>"}'
|
||||
echo "</ul>"
|
||||
echo "</li>"
|
||||
done
|
||||
echo "</ul></nav>"
|
||||
}
|
||||
|
||||
to-html(){
|
||||
local destination="$1"
|
||||
local toc="$(generate-html-toc)"
|
||||
echo "$toc"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue