From 24fc7f280636c7ea284e5cc4152681d8bc21d312 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Mon, 2 Jun 2008 14:58:54 +0000 Subject: [PATCH] * make script accept a path to use for an external script file * use it to have the search files as externals (which is significantly faster on some browsers (IE)) svn: r10089 original commit: 805c168236d0aa62151ac9c22989bd803d19ca58 --- collects/scribble/html-render.ss | 14 +++++++++----- collects/scribble/struct.ss | 4 ++-- collects/scribblings/scribble/struct.scrbl | 8 +++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 4e1ebf84..e96e87c6 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -721,11 +721,15 @@ `((span ([title ,(hover-element-text e)]) ,@(render-plain-element e part ri)))] [(script-element? e) - `((script ([type ,(script-element-type e)]) - ,(apply literal `("\n" ,@(script-element-script e) "\n"))) - ;; mynoscript hack doesn't always work (see hack in scribble-common.js) - (noscript ,@(render-plain-element e part ri)) - )] + (let* ([t `[type ,(script-element-type e)]] + [s (script-element-script e)] + [s (if (list? s) + `(script (,t) ,(apply literal `("\n" ,@s "\n"))) + `(script (,t [src ,s])))]) + (list s + ;; mynoscript hack doesn't always work (see the + ;; (commented) hack in scribble-common.js) + `(noscript ,@(render-plain-element e part ri))))] [(target-element? e) `((a ([name ,(format "~a" (anchor-name (tag-key (target-element-tag e) ri)))])) diff --git a/collects/scribble/struct.ss b/collects/scribble/struct.ss index 2ef0942f..dcad3625 100644 --- a/collects/scribble/struct.ss +++ b/collects/scribble/struct.ss @@ -166,7 +166,7 @@ [(aux-element element) ()] [(hover-element element) ([text string?])] [(script-element element) ([type string?] - [script (listof string?)])] + [script (or/c path-string? (listof string?))])] ;; specific renders support other elements, especially strings [with-attributes ([style any/c] @@ -176,7 +176,7 @@ [parent (or/c false/c part?)] [info any/c])] - [target-url ([addr (or/c string? path?)] [style any/c])] + [target-url ([addr path-string?] [style any/c])] [url-anchor ([name string?])] [image-file ([path (or/c path-string? (cons/c (one-of/c 'collects) diff --git a/collects/scribblings/scribble/struct.scrbl b/collects/scribblings/scribble/struct.scrbl index edcbdd23..cd0031f7 100644 --- a/collects/scribblings/scribble/struct.scrbl +++ b/collects/scribblings/scribble/struct.scrbl @@ -485,11 +485,13 @@ over the element's content.} @defstruct[(script-element element) ([type string?] - [script (listof string?)])]{ + [script (or/c path-string? + (listof string?))])]{ For HTML rendering, when scripting is enabled in the browser, @scheme[script] is used for the element instead of its normal -content. The @scheme[type] string is normally +content---it can be either path naming a script file to refer to, or +the contents of the script. The @scheme[type] string is normally @scheme["text/javascript"].} @@ -560,7 +562,7 @@ Computed for each part by the @techlink{collect pass}. } -@defstruct[target-url ([addr string?] +@defstruct[target-url ([addr path-string?] [style any/c])]{ Used as a style for an @scheme[element]. The @scheme[style] at this