On Sat, Sep 12, 2020 at 06:14:53AM -0700, Shriram Krishnamurthi wrote:
> I need a little help with `decode` vs `decode-flow` in Scribble. (Also, 
> this thread is about a question I wasn't able to find answered anywhere, so 
> hopefully it will lead to a solution that others can also use.)
> 
> Sometimes it's really useful to incorporate Markdown-formatted content into 
> the middle of a Scribble document. (Let's not argue about this, please!) My 
> assumption is that the Markdown document lives in a separate file (I'm not 
> trying to do any clever textual inlining). Thanks to Greg Hendershott, I'm 
> almost there! I use
> 
> https://github.com/greghendershott/markdown
> 
> Here are two versions of the inlining function:
> 
> @(require markdown markdown/scrib scribble/decode)
> 
> @(define (markdown-inline file)
>    (decode-flow
>        (xexprs->scribble-pres
>          (with-input-from-file file read-markdown))))
> 
> @(define (markdown-part file)
>    (decode
>        (xexprs->scribble-pres
>          (with-input-from-file file read-markdown))))
> 
> As a practical matter, `markdown-part` needs to take lots of extra 
> arguments to create the appropriate part instead of just producing a 
> title-less section. More importantly, you often don't want a separate 
> section: you just want to "splice" the content into the current context.
> 
> `markdown-inline` works great for this purpose, *except* if the included 
> Markdown file contains any sections of its own, e.g.,
> 
> This is text.
> 
> > Lorem ipsum
> 
> # Section
> 
> ## Subsection
> 
> Then I get this error:
> 
> decode-flow: contract violation
> 
>   expected: pre-flow?
> 
>   given: (part-start 0 #f '((part "section")) (style #f '()) '("Section"))
> Any recommendations on how to create a "splicing" version that also 
> respects having sub-sections, or is that impossible? (I've tried pulling 
> out parts of the `part`, etc., but without success.)
> 
> Thanks!
> 
> Shriram
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/3f0b1012-783d-464a-a0ed-66d3f29f8893n%40googlegroups.com.

This looks very useful.

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200912163734.pdin66tp3zzmxa2f%40topoi.pooq.com.

Reply via email to