From: Christian Heller Date: Mon, 2 Jan 2017 10:31:55 +0000 (+0100) Subject: Clean up heading logic for .rst and .md interpretation. X-Git-Url: https://plomlompom.com/repos/task?a=commitdiff_plain;h=13dfbc049a5d1a6a4f5b6f2453b39542779300b0;p=redo-blog Clean up heading logic for .rst and .md interpretation. --- diff --git a/README.md b/README.md index 420c151..a0071b3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ redo-blog ========= -small blog system using the redo build system +small blog system using the redo build system, with blog article files written +in (pandoc) Markdown or ReStructured Text. dependencies ------------ @@ -29,12 +30,12 @@ These files will be linked to symbolically in a directory ./public/. Some metadata files will also be generated below ./metadata/: For each article, there will be generated a .uuid and a .intermediate file; furthermore, files for -data used in ./feed.xml and ./index.html will be built there and can be edited -to customize the blog – namely the files url, author, uuid, title, index.tmpl, -index_snippet.tmpl, article.tmpl. +data used in ./feed.xml and ./index.html will, if non-existant, be built there +and can be edited to customize the blog – namely the files url, author, uuid, +title, index.tmpl, index_snippet.tmpl, article.tmpl. -recipe to use server-side with git ----------------------------------- +recipe to remotely manage a redo blog with git +---------------------------------------------- On your server, install the dependencies listed above. Then set up a repository for your blog files. Let's assume we want it to sit in our home directory and be @@ -76,8 +77,14 @@ Client-side, do this (obviously, replace server and username): git commit -m 'set up blog metadata' git push origin master -bugs ----- +bugs and peculiarities +---------------------- Don't create a index.rst or index.md in the redo-managed directory, that will break things. + +The article title is derived in .md files from a first line prefixed with "% ", +while all other headings are treated as sub-headings. In .rst files, the title +is derived from a heading that must be at the top of the document, and be of an +adornment style (such as underlining with "=") that must be used only once in +it. diff --git a/processor/metadata/article.tmpl.do b/processor/metadata/article.tmpl.do index 5cf9b3c..7a560ec 100644 --- a/processor/metadata/article.tmpl.do +++ b/processor/metadata/article.tmpl.do @@ -9,10 +9,10 @@ cat << EOF %BLOG_TITLE% +

%ARTICLE_TITLE_HTML%

-
%BODY% -
+
EOF diff --git a/processor/metadata/default.intermediate.do b/processor/metadata/default.intermediate.do index adcd2eb..a09d4b2 100644 --- a/processor/metadata/default.intermediate.do +++ b/processor/metadata/default.intermediate.do @@ -8,8 +8,8 @@ mdfile="../${1%.intermediate}.md" rstfile="../${1%.intermediate}.rst" if [ -f "$rstfile" ]; then redo-ifchange "$rstfile" - pandoc -f rst --template="$template" --mathml -t html5 "$rstfile" > "$3" + pandoc -f rst --template="$template" --mathml -t html5 "$rstfile" --base-header-level=2 > "$3" elif [ -f "$mdfile" ]; then redo-ifchange "$mdfile" - pandoc -f markdown --template="$template" --mathml -t html5 "$mdfile" > "$3" + pandoc -f markdown --template="$template" --mathml -t html5 "$mdfile" --base-header-level=2 > "$3" fi diff --git a/test/test_files/bar baz.html b/test/test_files/bar baz.html index f2321f9..418a91b 100644 --- a/test/test_files/bar baz.html +++ b/test/test_files/bar baz.html @@ -5,9 +5,12 @@ Yet another blog +

foo

-
+

bar

bar

-
+

bar

+

bar

+
\ No newline at end of file diff --git a/test/test_files/bar baz.md b/test/test_files/bar baz.md index 423430d..ffec597 100644 --- a/test/test_files/bar baz.md +++ b/test/test_files/bar baz.md @@ -1,2 +1,9 @@ % foo -bar + +# bar + +bar + +## bar + +bar diff --git a/test/test_files/feed.xml.ignoring b/test/test_files/feed.xml.ignoring index dde4369..364d700 100644 --- a/test/test_files/feed.xml.ignoring +++ b/test/test_files/feed.xml.ignoring @@ -15,6 +15,8 @@ <p>foo</p> +<h2 id="bar">bar</h2> +<p>baz</p> @@ -25,6 +27,9 @@ IGNORE +<h2 id="bar">bar</h2> +<p>bar</p> +<h3 id="bar-1">bar</h3> <p>bar</p> @@ -37,7 +42,9 @@ <p>this text contains some special characters: /;%'&quot;&gt;&lt;&amp;äöüß</p> +<h2 id="some-sub-heading">some sub-heading</h2> <p>and more than one paragraph</p> +<h2 id="another-sub-heading">another sub-heading</h2> <p>note that should be ignored but \ should give a backlash</p> diff --git a/test/test_files/foo.html b/test/test_files/foo.html index 61bb939..9eb95f5 100644 --- a/test/test_files/foo.html +++ b/test/test_files/foo.html @@ -5,11 +5,13 @@ Yet another blog +

a title with some nasty characters: &<>"' %BODY%

-

this text contains some special characters: /;%'"><&äöüß

+

some sub-heading

and more than one paragraph

+

another sub-heading

note that should be ignored but \ should give a backlash

-
+
\ No newline at end of file diff --git a/test/test_files/foo.rst b/test/test_files/foo.rst index cf4c2df..039ed41 100644 --- a/test/test_files/foo.rst +++ b/test/test_files/foo.rst @@ -3,6 +3,12 @@ a title with some nasty characters: &<>"' %BODY% this text contains some special characters: /;%'"><&äöüß +some sub-heading +---------------- + and more than one paragraph +another sub-heading +------------------- + note that \ should be ignored but \\ should give a backlash diff --git a/test/test_files/test.html b/test/test_files/test.html index 5915dd7..bd4b81f 100644 --- a/test/test_files/test.html +++ b/test/test_files/test.html @@ -5,9 +5,11 @@ Yet another blog +

foo bar baz

-

foo

-
+

bar

+

baz

+
\ No newline at end of file diff --git a/test/test_files/test.md b/test/test_files/test.md index 4416db1..267021a 100644 --- a/test/test_files/test.md +++ b/test/test_files/test.md @@ -1,2 +1,6 @@ % foo *bar* **baz** foo + +# bar + +baz