From cd24ca09bacfa8373cf243adaf70c5b12a018387 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 9 Jan 2023 00:00:02 -0600 Subject: Add $PHTML_OPTIONS --- vienna | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/vienna b/vienna index e192776..e1263ea 100755 --- a/vienna +++ b/vienna @@ -53,6 +53,8 @@ configure() { PAGE_TEMPLATE="${VIENNA_PAGE_TEMPLATE:-.page.tmpl.html}" INDEX_TEMPLATE="${VIENNA_INDEX_TEMPLATE:-.index.tmpl.html}" FEED_TEMPLATE="${VIENNA_FEED_TEMPLATE:-.feed.tmpl.xml}" + # Options + PHTML_OPTIONS="${VIENNA_PHTML_OPTIONS:-expand entities}" # File extensions PAGE_RAW_EXT="${VIENNA_PAGE_RAW_EXT:-htm}" # Logging @@ -237,6 +239,7 @@ PLUGINDIR="$PLUGINDIR" PAGE_TEMPLATE="$PAGE_TEMPLATE" INDEX_TEMPLATE="$INDEX_TEMPLATE" FEED_TEMPLATE="$FEED_TEMPLATE" +PHTML_OPTIONS="$PHTML_OPTIONS" # Edit this with your web server's file path WWW_ROOT= @@ -347,15 +350,26 @@ phtml() { # phtml < INPUT # &, <, > will be escaped unless prepended with \. Paragraphs where the # first character is < will be left as-is, excepting indentation on the # first line (an implementation detail). - sed -E \ - '/./{H;1h;$!d;}; x; - s#^[ \n\t]+[^<].*#&#; - t par; b; - :par; - s#([^\\])&#\1\&#g; s#\\&#\&#g; - s#([^\\])<#\1\<#g; s#\\<#<#g; - s#([^\\])>#\1\>#g; s#\\>#>#g; - s#.*#

&

#' + case "$PHTML_OPTIONS" in + *entities*) + _entities='s#([^\\])&#\1\&#g; + s#([^\\])<#\1\<#g; + s#([^\\])>#\1\>#g; + s#\\([&<>])#\1#g;' + ;; + *) _entities= + esac + sed -E ' + /./ {H;$!d}; x + s#^[ \n\t]+([^<].*)#\1# + t par; b end + :par + '"$_entities"' + s#.*#

&

# + :end + s#^[ \n\t]+## + $!a +' } meta_init() { # meta_init FILE @@ -394,7 +408,11 @@ meta() { # meta FIELD [FILE] filters() { # filters < INPUT ## The filters to run input through. # This is a good candidate for customization in .vienna.sh. - phtml + phtml | + case "$PHTML_OPTIONS" in + *expand*) expand ;; + *) cat ;; + esac } ### Site building -- cgit 1.4.1-21-gabe81