Skip to content

Instantly share code, notes, and snippets.

@bstro
Last active Feb 25, 2019
Embed
What would you like to do?
#lang pollen
◊; I have a custom tagged called `digram`. I use it like this:
◊digram{◊(lesser-yin)}
◊; I use this to render these characters: ⚌ ⚍ ⚎ ⚏
◊; I will be using these all over my document, but in this specific
◊; case, I need to render them much like they appear above: in a row.
◊; Eventually I will be rendering to HTML, Latex, PDF, and JSON (if I can
◊; figure out how). But for now, I am just concerned with HTML. I started
◊; with this idea (see pollen.rkt below for tag implementation):
◊digram-row{
◊digram-row-item{◊digram{◊(lesser-yin)}}
◊digram-row-item{◊digram{◊(greater-yin)}}
◊digram-row-item{◊digram{◊(lesser-yin)}}
◊digram-row-item{◊digram{◊(lesser-yin)}}
}
◊; digram-row would map to an <ol>, and digram-row-item to an <li>,
◊; but I felt that this was coupling my representation of the digram row
◊; a little too closely to the HTML output. I am wondering if it might not
◊; be better to shoot for something like this:
◊digram-row{
◊digram{◊(lesser-yin)}
◊digram{◊(greater-yin)}
◊digram{◊(lesser-yin)}
◊digram{◊(lesser-yin)}
}
◊; I would like digram-row to be able to look at its children and if it
◊; determines that one of its children is a digram, then wrap the digram
◊; in an <li> automatically. How do I do this?
◊; Thanks!
#lang racket/base
(define (digram . elements)
(case (current-poly-target)
[(txt) elements]
[else (txexpr 'span empty elements)]))
(define (digram-row . elements)
(case (current-poly-target)
[(txt) elements]
[else (txexpr 'ol empty elements)]))
(define (digram-row-item . elements)
(case (current-poly-target)
[(txt) elements]
[else (txexpr 'li empty elements)]))
(define (lesser-yin)
(case (current-poly-target)
[(txt) "figure out later"]
[else ""]))
(define (lesser-yang)
(case (current-poly-target)
[(txt) "figure out later"]
[else ""]))
(define (greater-yin)
(case (current-poly-target)
[(txt) "figure out later"]
[else ""]))
(define (greater-yang)
(case (current-poly-target)
[(txt) "figure out later"]
[else ""]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment