On this page:
6.1 Using pollen/  mode
6.2 HTML Snippet functions
html$-page-head
html$-page-body-open
html$-series-list
html$-article-open
html$-article-close
html$-article-listing-short
html$-page-footer
html$-page-body-close
html$-note-contents
html$-note-listing-full
html$-note-in-article
html$-notes-section
html$-paginate-navlinks
7.7

6 HTML snippets

 (require "snippets-html.rkt")

Each “snippet” module provides all (well most of) the document- and article-level blocks of structural markup necessary for a particular target output format; this one is for HTML. The idea is that any block of markup that might be reused across more than one template should be a function.

The functions in the snippets modules follow two conventions in this project:

6.1 Using pollen/mode

It’s worth looking at the source for this file to see how pollen/mode can be used to make it easy to write “mini-template” functions:

#lang pollen/mode racket/base
 
(define (html$-my-article title body-tx)
  string-append{
    <p><b>◊|title|</b><p>
    (->html body-tx)
  })

6.2 HTML Snippet functions

procedure

(html$-page-head [title close-head?])  non-empty-string?

  title : (or/c string? #f) = #f
  close-head? : boolean? = #t
Returns the <head> section of an HTML document.

If title is a string it will be used inside the <title> tag.

If you want to include additional stuff inside the <head>, you can set close-head? to #f to prevent it from including the closing </head> tag (you’ll have to add it yourself).

procedure

(html$-page-body-open [body-class])  non-empty-string?

  body-class : string? = ""
Returns the opening <body> and <main> tags and elements that immediately follow, such as site header, logo and navigation.

If body-class is a non-empty string, its contents will be included in the class attribute of the <body> tag.

Returns an HTML <section> containing a list of all series, grouped by their “plural nouns”. The grouped list will flow into columns on wider displays.

procedure

(html$-article-open pagenode 
  title-specified-in-doc? 
  title 
  pubdate) 
  non-empty-string?
  pagenode : pagenode?
  title-specified-in-doc? : boolean?
  title : txexpr?
  pubdate : string?
Returns the opening <article> tag and elements that immediately follow: permlink, publish date, and opening <section> tag.

The title-specified-in-doc? form changes the HTML markup structure used.

procedure

(html$-article-close footertext)  non-empty-string?

  footertext : string?
Returns a string containing a closing <section> tag, a <footer> element containing footertext, and a closing <article> tag. If footertext is empty, the <footer> element will be omitted.

procedure

(html$-article-listing-short pagenode    
  pubdate    
  title)  non-empty-string?
  pagenode : pagenode?
  pubdate : string?
  title : string?
Returns a string of HTML for an article as it would appear in a listing context in “short” form (date and title only, with link).

Returns an HTML <footer> tag for use at the bottom of each page.

Returns a string containing the page’s <footer> and closing tags.

procedure

(html$-note-contents disposition-mark    
  elems)  non-empty-string?
  disposition-mark : string?
  elems : (listof xexpr?)
Returns a string containing the body-elements of a note converted to HTML. If disposition-mark is not empty, a <span> containing it will be inserted as the first element of the first block-level element.

procedure

(html$-note-listing-full pagenode    
  note-id    
  title-html-flow    
  date    
  contents    
  [author    
  author-url])  non-empty-string?
  pagenode : pagenode?
  note-id : string?
  title-html-flow : string?
  date : string?
  contents : string?
  author : string? = (default-authorname)
  author-url : string? = ""
Returns a string containing the complete HTML markup for a note, including title, permlink, date, contents and author, suitable for display outside the context of its parent article.

procedure

(html$-note-in-article id    
  date    
  contents    
  author    
  author-url)  non-empty-string?
  id : string?
  date : string?
  contents : string?
  author : string?
  author-url : string?
Like html$-note-listing-full, but returns HTML for a note suitable for display inside its parent article.

procedure

(html$-notes-section note-htmls)  non-empty-string?

  note-htmls : string?
Returns the complete HTML for the Further Notes section of an article.

procedure

(html$-paginate-navlinks current-page    
  pagecount    
  basename)  string?
  current-page : exact-positive-integer?
  pagecount : exact-positive-integer?
  basename : string?
On the “blog”, the articles are split across multiple files: "blog-pg1.html", "blog-pg2.html", etc. This function provides a string containing HTML for a group of links that can be given within each file, to link to the pages that come before/after it.

The links are enclosed within <li> tags. It’s up to the calling site to provide the enclosing <ul> tag (in case any custom styling or IDs need to be applied).