back to index | | home .

new-entry.sh, 2th revision


blogs entry script, test on debian, requires bash, python-mardown. Optional: trentm/python-markdown2, jq.

folder/files structure. @ means symlink/shortcut, * is executable.

$ alias ll='ls -F --color=auto -h --group-directories-first -a|tail -n +3|column|tr -s ' \t' ' '|column -t > /tmp/file'  
$ ll;cat /tmp/file  
./========================================================  
b/                       blog_index.md@  removeComment.sh  
im/                      im_index.md@    .style.css  
md-sh/                   .index.html     style.css  
neoup/                   index.html      test@  
python-markdown2-2.3.7/  not_found.html  

b/========================================================  
00blogdex.html       26.htm  
.00blogdex-old.html  28.htm  
01.htm               29.htm  
...                  ...  

md-sh/====================================================  
bin/    22  blogdexHead.txt     index2.md          templist  
lib/    28  curljq.sh*          index.md           test-markdown.md  
oldmd/  29  entry-template.txt  index-md2html.sh*  todo.txt  
01      30  im@                 json               x-curljq*  
10      b@  imdexHead.txt       new-entry.sh*      z-pad.txt  

Basic Usage:

jump to Upload, Misc
new-entry.sh, index-md2html.sh
./new-entry.sh n 'blog title quote include'; make new file numeric order start with 01, no file extension. Script looks for the largest number and +1 as new filename. A message appears once hit enter. This step can be skip, but the format is important, check my blog examples below.

./new-entry.sh [h|h2|i|i2] #; h or h2 makes markdown copies in /tmp, then add 2 spaces end of each line. Parsing extras option if found on third line. And convert to html, sandwhich btwn entry-template.txt, in b/ or im/. i or i2 adds entry or change existing title base on file name (#.htm) to index.md or index2.md (only one entry per line not two, if seperate by comma the other one would be replace.). This script does not support multiple input, use for loop instead.


trentm/python-markdown2 from github can be standalone, no need for pip. By extracting its bin and lib folders to md-sh/, where new-entry.sh is located.
See its test/ for examples.
my blog examples: 30.md, 28.md
On third line of blog entry, <!-- extras: target-blank-links, spoiler,code-friendly, fenced-code-blocks, header-ids, nofollow, cuddled-lists --> Use one or multiple and ./new-entry.sh [h|h2] # could run with python2 ./bin/markdown2 --extras spoiler,code-friendly,... Spacing is not important during inspection but spelling is. Start the blog content on 5th line and leave blank line after any heading #, code block ``` etc. Some difference btwn this and the deb package.

./index-md2html.sh $1; just update a index. $1 can be nothing or anything, for b/ or im/ and sandwhich btwn blogdexHead.txt or imdexHead.txt. No per links limit.

Upload:

x-curljq, curljq.sh
x-curljq import functions from the latter for easier editing. Examples are in it and file path for key variable and curljq.sh need to change. Run ./x-curljq once done.

Misc:

the index.html is not updated by script, style.css removes newline before upload.

I type in txt editor, no live preview. Can be annoying sometimes.

# On debian python-markdown 2.6.8-1 is not same as trentm/python-markdown2  
# Python-Markdown/markdown  
cat $input| markdown_py > $output;  
markdown_py $input > $output;  

-------------------------------------------------  
# trentm/python-markdown2-2.3.7  
# Extract bin, and lib folder out the release. test/ has more examples  
extra=name1,name2...  
extra=fenced-code-blocks,nofollow,cuddled-lists  
python2 ./bin/markdown2 --extras $extra > $output;  
python2 ./bin/markdown2 -x nofollow -x header-ids $input  

# some extra doesn't work, like 'use-file-vars'  
$ cat 02  
### titles here!  
----  
<!-- extras: header-ids, nofollow, tables -->  

start here if use extra, see git for more info.  
work or not, no promises.