mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-12-23 04:21:58 +00:00
render text files too
This commit is contained in:
parent
8dbab1b9f2
commit
12c2e63f83
38
notes2web
38
notes2web
@ -6,6 +6,8 @@
|
||||
# set default config values, load user config, export config variables
|
||||
name=""
|
||||
article_template="/opt/notes2web/templates/article.html"
|
||||
textarticlehead_template="/opt/notes2web/templates/textarticlehead.html"
|
||||
textarticlefoot_template="/opt/notes2web/templates/textarticlefoot.html"
|
||||
listitem_template="/opt/notes2web/templates/listitem.html"
|
||||
index_template="/opt/notes2web/templates/index.html"
|
||||
stylesheet="/opt/notes2web/styles.css"
|
||||
@ -17,6 +19,8 @@ done
|
||||
|
||||
export name
|
||||
export article_template
|
||||
export textarticlehead_template
|
||||
export textarticlefoot_template
|
||||
export listitem_template
|
||||
export index_template
|
||||
export stylesheet
|
||||
@ -29,16 +33,39 @@ function _renderarticle {
|
||||
--standalone\
|
||||
-t html\
|
||||
--template "$article_template"\
|
||||
-o "$(dirname "$1")/index.html"\
|
||||
-o "${1}.html"\
|
||||
"$1"\
|
||||
--mathjax
|
||||
}
|
||||
|
||||
|
||||
function _rendertextarticle {
|
||||
[[ "$(file -b "$1")" == "ASCII text" ]] || exit
|
||||
echo "rendering text file $1"
|
||||
sed -e "s#\\\$title\\\$#$1#" "$textarticlehead_template"\
|
||||
> "${1}.html"
|
||||
cat "$1" >> "${1}.html"
|
||||
cat "$textarticlefoot_template" >> "${1}.html"
|
||||
}
|
||||
|
||||
|
||||
function _adddirtoindex {
|
||||
dir="$(dirname "$1")"
|
||||
echo "<h2>$(basename "$dir") notes</h2>" >> index.md
|
||||
find "$dir" -name '*.md' -exec bash -c "_addarticletoindex '{}'" \;
|
||||
find "$dir" -not -path '**/.git/**' -not -name '*.md' -type f -exec bash -c "_addtextarticletoindex '{}'" \;
|
||||
}
|
||||
|
||||
|
||||
function _addtextarticletoindex {
|
||||
[[ "$(file -b "$1")" == "ASCII text" ]] || exit
|
||||
pandoc\
|
||||
-t html\
|
||||
-V "filepath=${1}.html"\
|
||||
-V "title=$1"\
|
||||
--template "$listitem_template"\
|
||||
"$1"\
|
||||
>> index.md
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +73,7 @@ function _addarticletoindex {
|
||||
echo "adding $1 to list of notes"
|
||||
pandoc\
|
||||
-t html\
|
||||
-V "filepath=$(dirname "$1")"\
|
||||
-V "filepath=${1}.html"\
|
||||
--template "$listitem_template"\
|
||||
"$1"\
|
||||
>> index.md
|
||||
@ -54,14 +81,17 @@ function _addarticletoindex {
|
||||
|
||||
|
||||
export -f _renderarticle
|
||||
export -f _rendertextarticle
|
||||
export -f _adddirtoindex
|
||||
export -f _addarticletoindex
|
||||
export -f _addtextarticletoindex
|
||||
|
||||
|
||||
#render each markdown file in every folder passed in args
|
||||
for file in "$@"
|
||||
for dir in "$@"
|
||||
do
|
||||
find "$file" -name '*.md' -exec bash -c "_renderarticle '{}'" \;
|
||||
find "$dir" -name '*.md' -exec bash -c "_renderarticle '{}'" \;
|
||||
find "$dir" -not -path '**/.git/**' -not -name '*.md' -type f -exec bash -c "_rendertextarticle '{}'" \;
|
||||
done
|
||||
|
||||
|
||||
|
@ -36,6 +36,8 @@ Default config values:
|
||||
```bash
|
||||
name=""
|
||||
article_template="/opt/notes2web/templates/article.html"
|
||||
textarticlehead_template="/opt/notes2web/templates/textarticlehead.html"
|
||||
textarticlefoot_template="/opt/notes2web/templates/textarticlefoot.html"
|
||||
listitem_template="/opt/notes2web/templates/listitem.html"
|
||||
index_template="/opt/notes2web/templates/index.html"
|
||||
stylesheet="/opt/notes2web/styles.css"
|
||||
|
3
templates/textarticlefoot.html
Normal file
3
templates/textarticlefoot.html
Normal file
@ -0,0 +1,3 @@
|
||||
</pre>
|
||||
<p style="font-size: 0.7em;"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a></p>
|
||||
</body>
|
15
templates/textarticlehead.html
Normal file
15
templates/textarticlehead.html
Normal file
@ -0,0 +1,15 @@
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
|
||||
<link rel="stylesheet" type="text/css" href="/styles.css" />
|
||||
<title>$title$</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>$title$</h1>
|
||||
<p> This file was not rendered by notes2head because it is a plaintext file, not a markdown
|
||||
file.
|
||||
Below is an unformatted representation of the file:
|
||||
</p>
|
||||
<pre>
|
Loading…
Reference in New Issue
Block a user