4 ms·
Pandoc powers my little static site maker: cf. https://github.com/adityaathalye/shite/blob/master/bin/templating.sh#L112 https://github.com/adityaathalye/shite
by adityaathalye 4y ago
Pandoc powers my little static site maker:
cf. https://github.com/adityaathalye/shite/blob/master/bin/templating.sh#L112 https://github.com/adityaathalye/shite/blob/master/bin/templ...
__shite_templating_compile_source_to_html() {
# If content has front matter metadata, it is presumed to be in a format
# that the content compiler can safely process and elide or ignore.
local file_type=${1:?"Fail. We expect file type of content like html, org, md etc."}
case ${file_type} in
html )
pandoc -f html -t html
;;
md )
pandoc -f markdown -t html
;;
org )
pandoc -f org -t html
;;
esac
}
- BeetleB 4y agoMine too. I author in org and have a plugin that converts the org files to rst files.
- adityaathalye 4y agoAh, I make it compile partial HTML (just page content), and stick that into my own HTML page template(s) (written as HEREDOCS :D). That's part of the joy of using Pandoc. I can pipeline it, no problem. Like this: cf. https://github.com/adityaathalye/shite/blob/master/bin/templating.sh#L219 https://github.com/adityaathalye/shite/blob/master/bin/templ... cat "${watch_dir}/sources/${url_slug}" | __shite_templating_compile_source_to_html ${file_type} | __shite_templating_wrap_content_html ${content_type} ${watch_dir} | __shite_templating_wrap_page_html \ > "${watch_dir}/public/${html_url_slug}" Templates look like this. Notice the $(cat -) in the middle. That's how the HTML content produced by Pandoc gets injected in the middle of everything else. shite_template_common_default_page() { local maybe_page_id=${shite_page_data[page_id]:+"id=\"${shite_page_data[page_id]}\""} local maybe_canonical_url=${shite_page_data[canonical_url]:+"<link rel=\"canonical\" href=\"${shite_page_data[canonical_url]}\">"} cat <<EOF <!DOCTYPE html> <html lang="en"> <head> $(shite_template_common_meta) $(shite_template_common_links) ${maybe_canonical_url} </head> <body ${maybe_page_id}> <div id="the-very-top" class="stack center box"> $(shite_template_common_header) <main id="main"> $(cat -) </main> $(shite_template_common_footer) </div> </body> </html> EOF } edit: substantiate Pandoc's role.
- BeetleB 4y agoIn my case I'm using Pelican which has builtin support for rst, so it was easier for me to just convert to rst rather than full blown HTML.
- adityaathalye 4y agoSince I've rolled my own SSG, I wanted it to compile $FORMAT -> HTML directly, so I write fewer bugs :D I chose Pandoc because it does a reasonably OK job compiling orgmode, _and_ has good support for other formats I use from time to time (e.g. markdown, ASCIIDOC). Before this, I was using hugo, with a compile cycle similar to your setup, viz. org -> markdown (via ox-hugo), and then hugo did the md -> HTML thing. hugo sort of supports org -> html, but their batteries-included compiler is not very good. Points for trying, though. edit: typo, context