* change script-element to take a list of strings, pad it with newlines
* make links from the outside the plt going inside be absolute links svn: r9962 original commit: 00a5391be263831ac2d8b43fd2924926acea78cd
This commit is contained in:
parent
e8189aa62b
commit
8aec4f586d
|
@ -9,6 +9,7 @@
|
||||||
mzlib/runtime-path
|
mzlib/runtime-path
|
||||||
setup/main-doc
|
setup/main-doc
|
||||||
setup/main-collects
|
setup/main-collects
|
||||||
|
setup/dirs
|
||||||
net/url
|
net/url
|
||||||
net/base64
|
net/base64
|
||||||
scheme/serialize
|
scheme/serialize
|
||||||
|
@ -705,7 +706,7 @@
|
||||||
,@(render-plain-element e part ri)))]
|
,@(render-plain-element e part ri)))]
|
||||||
[(script-element? e)
|
[(script-element? e)
|
||||||
`((script ([type ,(script-element-type e)])
|
`((script ([type ,(script-element-type e)])
|
||||||
,(literal (script-element-script e)))
|
,(apply literal `("\n" ,@(script-element-script e) "\n")))
|
||||||
(mynoscript ,@(render-plain-element e part ri)))]
|
(mynoscript ,@(render-plain-element e part ri)))]
|
||||||
[(target-element? e)
|
[(target-element? e)
|
||||||
`((a ([name ,(format "~a" (anchor-name (tag-key (target-element-tag e)
|
`((a ([name ,(format "~a" (anchor-name (tag-key (target-element-tag e)
|
||||||
|
@ -1063,11 +1064,42 @@
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
;; utils
|
;; utils
|
||||||
|
|
||||||
|
(define (explode p)
|
||||||
|
(reverse (let loop ([p p])
|
||||||
|
(let-values ([(base name dir?) (split-path p)])
|
||||||
|
(let ([name (if base
|
||||||
|
(if (path? name)
|
||||||
|
(path-element->string name)
|
||||||
|
name)
|
||||||
|
name)])
|
||||||
|
(if (path? base)
|
||||||
|
(cons name (loop base))
|
||||||
|
(list name)))))))
|
||||||
|
|
||||||
|
(define in-plt?
|
||||||
|
(let ([roots (map explode (list (find-doc-dir) (find-collects-dir)))])
|
||||||
|
(lambda (path)
|
||||||
|
(ormap (lambda (root)
|
||||||
|
(let loop ([path path] [root root])
|
||||||
|
(or (null? root)
|
||||||
|
(and (pair? path)
|
||||||
|
(equal? (car path) (car root))
|
||||||
|
(loop (cdr path) (cdr root))))))
|
||||||
|
roots))))
|
||||||
|
|
||||||
(define (from-root p d)
|
(define (from-root p d)
|
||||||
(if (not d)
|
(define e-p (explode (path->complete-path p (current-directory))))
|
||||||
|
(define e-d (and d (explode (path->complete-path d (current-directory)))))
|
||||||
|
(define p-in? (in-plt? e-p))
|
||||||
|
(define d-in? (and d (in-plt? e-d)))
|
||||||
|
;; use an absolute link if the link is from outside the plt tree
|
||||||
|
;; going in (or if d is #f)
|
||||||
|
(if (not (and d (cond [(equal? p-in? d-in?) #t]
|
||||||
|
[d-in? (error 'from-root
|
||||||
|
"got a link from the PLT going out; ~e"
|
||||||
|
p)]
|
||||||
|
[else #f])))
|
||||||
(url->string (path->url (path->complete-path p)))
|
(url->string (path->url (path->complete-path p)))
|
||||||
(let ([e-d (explode (path->complete-path d (current-directory)))]
|
|
||||||
[e-p (explode (path->complete-path p (current-directory)))])
|
|
||||||
(let loop ([e-d e-d] [e-p e-p])
|
(let loop ([e-d e-d] [e-p e-p])
|
||||||
(cond
|
(cond
|
||||||
[(null? e-d)
|
[(null? e-d)
|
||||||
|
@ -1081,16 +1113,4 @@
|
||||||
[(eq? 'same (car e-d)) (loop (cdr e-d) e-p)]
|
[(eq? 'same (car e-d)) (loop (cdr e-d) e-p)]
|
||||||
[(eq? 'same (car e-p)) (loop e-d (cdr e-p))]
|
[(eq? 'same (car e-p)) (loop e-d (cdr e-p))]
|
||||||
[else (string-append (string-append* (map (lambda (x) "../") e-d))
|
[else (string-append (string-append* (map (lambda (x) "../") e-d))
|
||||||
(loop null e-p))])))))
|
(loop null e-p))]))))
|
||||||
|
|
||||||
(define (explode p)
|
|
||||||
(reverse (let loop ([p p])
|
|
||||||
(let-values ([(base name dir?) (split-path p)])
|
|
||||||
(let ([name (if base
|
|
||||||
(if (path? name)
|
|
||||||
(path-element->string name)
|
|
||||||
name)
|
|
||||||
name)])
|
|
||||||
(if (path? base)
|
|
||||||
(cons name (loop base))
|
|
||||||
(list name)))))))
|
|
||||||
|
|
|
@ -162,7 +162,7 @@
|
||||||
[(aux-element element) ()]
|
[(aux-element element) ()]
|
||||||
[(hover-element element) ([text string?])]
|
[(hover-element element) ([text string?])]
|
||||||
[(script-element element) ([type string?]
|
[(script-element element) ([type string?]
|
||||||
[script string?])]
|
[script (listof string?)])]
|
||||||
;; specific renders support other elements, especially strings
|
;; specific renders support other elements, especially strings
|
||||||
|
|
||||||
[with-attributes ([style any/c]
|
[with-attributes ([style any/c]
|
||||||
|
|
|
@ -484,7 +484,7 @@ over the element's content.}
|
||||||
|
|
||||||
|
|
||||||
@defstruct[(script-element element) ([type string?]
|
@defstruct[(script-element element) ([type string?]
|
||||||
[script string?])]{
|
[script (listof string?)])]{
|
||||||
|
|
||||||
For HTML rendering, when scripting is enabled in the browser,
|
For HTML rendering, when scripting is enabled in the browser,
|
||||||
@scheme[script] is used for the element instead of its normal
|
@scheme[script] is used for the element instead of its normal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user