mbutterick/quad

Paragraph decoding in nested blocks

Closed this issue · 2 comments

I've followed the Quad tutorial to tackle a Pollen project that until now has only exported html. I'm using poly targets, and after very little hassle it's all up and running. It's exciting stuff and I've been looking forward to this for a long time.

Paragraphs are automatically detected using the decode-paragraphs bit of the tutorial as follows:

(define (root . xs)
  `(q ,@(add-between (decode-paragraphs xs 'q) para-break)))

My Pollen markup produces html slides, and it's nested like this:

<section class="slide">
<h2>Slide Heading</h2>

<p>Slide content begins here.</p>

<p>And continues…</p>
</section>

The tag looks like this: ◊slide["Slide Heading"]{Slide content begins here.

When it comes to Quad, I would like to be able to do the following:

(define (slide title . content)
  (case (current-poly-target)
    [(pdf) 
        '(q ((font-family "heading")) ,title)
        content]))

However Quad will not accept content like that:

decode-paragraphs: contract violation
  expected: txexpr-elements?
  given: '((q (q ((font-family "heading")) "Slide Heading") (q ((break "para"))) ("Slide content begins here." "\n" "\n"

I'm able to resolve this by ensuring that content is wrapped inside a q:

`(q 
  (q ((font-family "heading")) ,title)
  (q ((break "para")))
  (q ,@content))

However, as you can see I needed to inside a manual paragraph break in there to separate the heading from the content, and more importantly none of the paragraphs inside this content block are detected. They all get lumped together in one paragraph.

I'm not sure what the best way to approach this is, so would be really grateful for any advice.

What about something like this? (Roughly — haven’t tried it)

`(q 
  (q ((font-family "heading")) ,title)
  (q ,@(add-between (decode-paragraphs content 'q) para-break)))

Thank you so much, @mbutterick .