squeeze

A static site generator that can put the toothpaste back in the tube.
git clone https://git.mulligrubs.me/squeeze
Log | Files | Refs | README | LICENSE

commit d4f0c1255fb63988a0cd370b15eb4bbc1757f8ba
parent 6c976763f193e3016e660facc7a15558a79dc069
Author: St John Karp <contact@stjo.hn>
Date:   Mon,  5 Jul 2021 07:28:30 -0500

Add support for a separate "clean title"

This allows the HTML <title> tag to use a different value from
the one in the article itself, which may be desirable for supporting
HTML tags in the article title. I've implemented support for replacing
the <cite> tag with numeric double quote entities.

Diffstat:
Mexample/html.pl | 16++++++++--------
Mgenerate_rss.pl | 2+-
Mparse_entry.pl | 15+++++++++++++--
3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/example/html.pl b/example/html.pl @@ -4,25 +4,25 @@ % This is basically your static website's template. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -page(Entry, Title, Subtitle, Date) --> +page(Entry, Title, Subtitle, Date, CleanTitle) --> doctype, newline, - html(Entry, Title, Subtitle, Date), + html(Entry, Title, Subtitle, Date, CleanTitle), newline. -html(Entry, Title, Subtitle, Date) --> +html(Entry, Title, Subtitle, Date, CleanTitle) --> html_open, newline, - head(Title), + head(CleanTitle), newline, body(Entry, Title, Subtitle, Date), newline, html_close. -head(Title) --> +head(CleanTitle) --> head_open, newline, tab, - title(Title), + title(CleanTitle), newline, tab, meta, newline, tab, @@ -123,9 +123,9 @@ title(null) --> site_subtitle, "</title>". -title(Title) --> +title(CleanTitle) --> "<title>", - anything(Title), + anything(CleanTitle), "</title>". styles --> diff --git a/generate_rss.pl b/generate_rss.pl @@ -57,7 +57,7 @@ files_to_articles([Filename|Filenames], [article(FormattedDate, FormattedTitle, % Grab the link. get_link(Filename, Link), % Extract the title, entry, etc. from the HTML. - page(Entry, Title, _, Date, HTML, []), + page(Entry, _, _, Date, Title, HTML, []), % Format the date according to RFC 822. format_date(FormattedDate, Date), % XML escape the description. diff --git a/parse_entry.pl b/parse_entry.pl @@ -31,7 +31,7 @@ parse_entry(Filename):- % parse_html(+HTML). % Parse HTML into a Markdown file and write to stdout. parse_html(HTML):- - page(EntryCodes, Title, Subtitle, Date, HTML, []), + page(EntryCodes, Title, Subtitle, Date, _, HTML, []), markdown(EntryCodes, Title, Subtitle, Date, MarkdownCodes, []), write_codes(user_output, MarkdownCodes), halt. @@ -57,6 +57,17 @@ generate_entry(Filename):- generate_html(Markdown):- markdown(EntryCodes, Title, Subtitle, Date, Markdown, []), markdown_to_html(EntryCodes, HTMLEntryCodes), - page(HTMLEntryCodes, Title, Subtitle, Date, HTMLCodes, []), + clean_title(Title, CleanTitle), + page(HTMLEntryCodes, Title, Subtitle, Date, CleanTitle, HTMLCodes, []), write_codes(user_output, HTMLCodes), halt. + + +% clean_title(+Title, -CleanTitle). +% Replace select HTML tags in an entry title to make it suitable +% for an HTML title. +clean_title(null, null). + +clean_title(Title, CleanTitle):- + replace("<cite>", "&#8220;", Title, Title1), + replace("</cite>", "&#8221;", Title1, CleanTitle).