[racket] Scribble: Different output for LaTeX and HTML backends
Maybe too late for your purposes, but...
At Tue, 7 Dec 2010 16:27:42 +0100, Jens Axel Søgaard wrote:
> I have a YouTube video, that I'd like to embed in the HTML output using the
> following code:
>
> <iframe title="YouTube video player" class="youtube-player"
> type="text/html" width="480" height="390"
> src="http://www.youtube.com/embed/J3WIPS3Uh_A?rel=0"
> frameborder="0"></iframe>
>
> In the PDF version, I'd like to use:
>
> @hyperlink["http://www.youtube.com/watch?v=J3WIPS3Uh_A"]{Proof for the
> cosine relation in an acute trinagle}
>
> How can I detect whether pdf or html is being generated?
> Is there a parameter I can use?
I've finally added support for conditional content through a new
`scriblib/render-cond' library (which builds on a small core addition
to `traverse-element' and `traverse-block' plus).
Here's an example:
#lang scribble/base
@(require scriblib/render-cond
scribble/core)
@(cond-element
[latex (make-element "LaTeX" "")]
[html "HTML"]
[text "Text"])
is the best document format ever!
At Wed, 8 Dec 2010 14:06:45 +0100, Jens Axel Søgaard wrote:
> It (finally) dawned on me that I have two problems.
> I thougt this would display a YouTube player on the HTML page:
>
> @exact|{<iframe title="YouTube video player" class="youtube-player"
> type="text/html" width="480" height="390"
> src="http://www.youtube.com/embed/J3WIPS3Uh_A?rel=0"
> frameborder="0"></iframe>}|
>
> But since the element passes through the renderer, I get the above
> string displayed as is on the HTML page.
> Is there a loop hole that allows one to pass HTML untouched through
> the renderer?
I'm reluctant to make 'exact affect HTML output or to otherwise resort
to literal string inclusion. The `attributes' structure from
`scribble/html-attributes' lets you add arbitrary attributes to HTML
output, and I've added an `alt-tag' structure to pick a tag such as
<iframe>:
#lang scribble/base
@(require scribble/core
scribble/html-properties)
@(make-element
(make-style #f
(list
(make-alt-tag "iframe")
(make-attributes
`((title . "YouTube video player")
(class . "youtube-player")
(type . "text/html")
(width . "480")
(height . "390")
(src . "http://www.youtube.com/embed/J3WIPS3Uh_A?rel=0")
(frameborder . "0")))))
null)