I am trying to use Scribble to generate HTML documents (blog-like, but not 
exactly, so Frog doesn't meet my needs) but would really like to eliminate 
the material in the left gutter (TOC). (Ideally I'd also like to suppress 
the author tag.)

I've spent some time going through the source of Greg Hendershott's Frog 
and Ryan Culpepper's Scriblogify and both seem to use essentially the same 
technique, which is a total hack: call Scribble to generate the HTML, then 
go into it and search for a particular DOM structure to extract the "main 
content". For instance, Scriblogify does this

(define (get-blog-entry file)

  (let* ([doc (call-with-input-file file html->xexp)]

         [title ((sxpath "//title/text()") doc)]

         [title (and (pair? title) (car title))]

         [content

          ((sxpath 
"//div[@class='SAuthorListBox']/following-sibling::node()") doc)]

while Frog does

  ;; Extract the part we care about -- the elements in the "main" div

  ;; after the "versionbox" div.  (The `match` might be too fragile

  ;; way to do this.)

  (match (~> (build-path dir "frog.html")

             (with-input-from-file read-html-as-xexprs)

             cadr)

    ; HTML produced from #scribble/manual

    [`(html

       ()

       (head . ,_)

       ,(list-no-order

         `(div ([class "maincolumn"])

               (div ([class "main"])

                    (div ([class "versionbox"])

                         (span ([class "versionNoNav"]) ,_))

                    . ,xs))

         _ ...))

     (adjust-scribble-html xs img-uri)]

(it actually has different patterns depending on the Scribble language 
used!).

What's a better, cleaner way of doing this? I *suppose* one could build a 
whole renderer, which seems like an insane amount of work. Hopefully 
there's a way of doing this as a "delta" on the existing renderer, but I 
haven't had any luck finding an example of a custom renderer that, say, 
suppresses the printing of the TOC and/or the author list but leaves the 
rest of the page alone.

[Yes, I could set up the CSS so that the TOC appears hidden, but it would 
still be present in the source and could be found by one of several means. 
I would really like it to not be there. And I hope there's a better way of 
doing it than modifying the JavaScript to, on load, go and delete the 
undesired elements…]

Any ideas/suggestions/pointers? 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/246966eb-3521-40fe-93c5-b4bf6a81379eo%40googlegroups.com.

Reply via email to