diff options
author | Zhiming Wang <zmwangx@gmail.com> | 2015-05-04 18:45:17 -0700 |
---|---|---|
committer | Zhiming Wang <zmwangx@gmail.com> | 2015-05-04 18:45:17 -0700 |
commit | 07bf43a314fe65ccd9c7cb663c3c6134a47cc269 (patch) | |
tree | 93104d3f07143b1e62d773d95dd973888cdd7f27 /tools | |
parent | ee374553f2ba385157eec9a816cf9b023fbfb18a (diff) | |
download | my_new_personal_website-07bf43a314fe65ccd9c7cb663c3c6134a47cc269.tar.xz my_new_personal_website-07bf43a314fe65ccd9c7cb663c3c6134a47cc269.zip |
edit posts and (mostly) figured out the theme
Also wrote pyblog that currently can generate parts most of the blog.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/convert-from-octopress.awk | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/convert-from-octopress.awk b/tools/convert-from-octopress.awk new file mode 100755 index 00000000..20556044 --- /dev/null +++ b/tools/convert-from-octopress.awk @@ -0,0 +1,36 @@ +#!/usr/bin/env gawk -f +/---/ { meta_delim_count++ } +{ + if (meta_delim_count >= 2) { + # remove additional metadata (title, url, link text) other than the + # language from a Octopress fenced (backtick) code block + if (match($0, /\s*```\s*[[:alnum:]_-]+/, matchobj)) { + print matchobj[0] + next + } + + # convert Octopress {% %} plugin blocks to verbatim (in fenced code + # blocks); this can't really handle multiline plugins (e.g., + # blockquote), but sacrifices need to be made anyway + if (match($0, /\s*{%.+%}\s*/)) { + print "```" + print + print "```" + next + } + + # correct internal links + $0 = gensub(/\/blog\/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/([a-zA-Z0-9%_-]+)\//, \ + "/blog/\\1-\\2-\\3-\\4.html", "g") + print + } else if ($1 == "layout:" || $1 == "comments:" || $1 == "categories:") { + next + } else if ($1 == "date:") { + print + printf "date-display: " + # requires date from coreutils; BSD date doesn't work + system("date -d "$2" +'%B %_d, %Y'") + } else { + print + } +} |