typesanitizer
typesanitizer

Reputation: 2775

Debugging Scribble's (need a pre-part for decode) error

Consider the following Scribble document:

#lang scribble/manual

@title[#:tag "MyTitle"]{MyTitle}

@(module bq racket/base
    (require scribble/html/html)
    (provide blockquote))
@(require 'bq)

@blockquote{
   "Ho, ho, ho! -- Santa Claus."
}

If I try building this with scribble --dest . test.scrbl, it fails with

/Users/varun/Code/test.scrbl:10:0: not valid in document body (need a pre-part for decode) in: (element 'blockquote '() '("\"Ho, ho, ho! -- Santa Claus.\"") #f)
  context...:
   body of "/Users/varun/Code/test.scrbl"
   .../private/map.rkt:40:19: loop
   .../racket/cmdline.rkt:191:51
   body of "/Applications/Racket v8.0/share/pkgs/scribble-lib/scribble/run.rkt"

I don't understand the error. What "pre-part" is it referring to? I found a blog post "Writing a paper in Scribble" which describes a similar error; there, the problem is that a number isn't converted to a string. However, I do have a string here, so I don't understand what the issue is.

Upvotes: 0

Views: 91

Answers (2)

typesanitizer
typesanitizer

Reputation: 2775

Based on what Sam said in his answer, as well as a similar comment on Twitter, I ended up defining a blockquote as:

@(require scribble/core scribble/decode)
@(define (blockquote . strs)
      (make-nested-flow (make-style "blockquote" '(command))
                        (decode-flow strs)))

(Source: https://sourcegraph.com/github.com/flock-lab/flock/-/blob/docs/main.scrbl?L9-L11)

This can be used without quotes:

@blockquote{Ho, ho, ho! -- Santa Claus.}

Upvotes: 0

Sam Tobin-Hochstadt
Sam Tobin-Hochstadt

Reputation: 5053

The problem is that scribble/html is not connected to scribble/manual, and the "element" constructed there is an HTML element. You can't use the functions from scribble/html in a document like this.

If you want a block quote in scribble, you probably want to use nested-flow.

Upvotes: 1

Related Questions