Skip to content

Linking to images from Scribble files #227

@cwebber

Description

@cwebber

It would be good to be able to link to images in the img/ directory in Scribble files. Using @image isn't great because Racket copies the image in question into memory and then writes it out again rather than just using what's already there.

I tried doing this using something like:

#lang scribble/manual

@(require frog/scribble
          scribble/core
          scribble/html-properties)

@(elem
  #:style
  (style #f
         (list (alt-tag "img")
               (attributes '((src . "/img/IMG_20170918_155136272_HDR.jpg")
                             (beep . "boop"))))))

I was surprised to find that the outputted html looked like so:

<img src="/Test//img/IMG_20170918_155136272_HDR.jpg" beep="boop" />

Why did src get modified? I tried running this with the plain scribble command line tool, no Frog involved, and it was fine.

I think I found the source of the problem in frog/private/read-scribble.rkt:

(define (adjust-scribble-html xs img-uri)
  (for/list ([x (in-list xs)])
    (xexpr-map
     (lambda (x _)
       (list
        (match x
          [`(blockquote ([class "SCodeFlow"]) . ,xs)
           `(div ([class "SCodeFlow"]) ,@xs)]
          [`(img ,(list-no-order `[src ,src] x ...))
           `(img ([src ,(str img-uri "/" src)] ,@x))]
          ...))))))

which is being called from write-non-post-page in non-posts.rkt. So it looks like all image src's are being rewritten by Frog, even in the case where this isn't desired.

Happy to submit a patch to fix this... but I guess this was intentionally transforming the html for some reason, and I'm not sure on this layer how to only rewrite certain images but not others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions