Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | added to-html and tree-trans to sxml |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2e060a1291731b48469de9e1f3e76ed3 |
User & Date: | aldo 2016-12-05 22:28:44 |
Context
2016-12-08
| ||
00:35 | added posix.sls check-in: a6f2950586 user: aldo tags: trunk | |
00:28 | added posix lib Closed-Leaf check-in: 53d7f67914 user: aldo tags: trunk | |
2016-12-05
| ||
22:28 | added to-html and tree-trans to sxml check-in: 2e060a1291 user: aldo tags: trunk | |
22:06 | added sxml check-in: 837939cf40 user: aldo tags: trunk | |
Changes
Added sxml/to-html.sls.
> > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
(library (sxml to-html) (export SXML->HTML string->goodHTML entag enattr) (import (except (scheme) string-copy string-for-each string->list string-upcase string-downcase string-titlecase string-hash string-copy! string-fill! fold-right error filter) (prefix (only (scheme) error) scheme:) (srfi s13 strings) (sxml tree-trans)) (include "utils.ss") (include "SXML-to-HTML.scm")) |
Added sxml/tree-trans.sls.
> > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
(library (sxml tree-trans) (export SRV:send-reply pre-post-order post-order foldts replace-range) (import (except (scheme) string-copy string-for-each string->list string-upcase string-downcase string-titlecase string-hash string-copy! string-fill! fold-right error filter) (prefix (only (scheme) error) scheme:) (srfi s13 strings)) (include "utils.ss") (include "SXML-tree-trans.scm")) |
Changes to sxml/utils.ss.
455 456 457 458 459 460 461 |
(if (char=? (string-ref str k) (string-ref str (+ i k))) (loop (inc k)) (backtrack (inc i) matched-substr-len))))))))) (match-1st-char))) (define find-string-from-port? miscio:find-string-from-port?) |
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
(if (char=? (string-ref str k) (string-ref str (+ i k))) (loop (inc k)) (backtrack (inc i) matched-substr-len))))))))) (match-1st-char))) (define find-string-from-port? miscio:find-string-from-port?) ; make-char-quotator QUOT-RULES ; ; Given QUOT-RULES, an assoc list of (char . string) pairs, return ; a quotation procedure. The returned quotation procedure takes a string ; and returns either a string or a list of strings. The quotation procedure ; check to see if its argument string contains any instance of a character ; that needs to be encoded (quoted). If the argument string is "clean", ; it is returned unchanged. Otherwise, the quotation procedure will ; return a list of string fragments. The input straing will be broken ; at the places where the special characters occur. The special character ; will be replaced by the corresponding encoding strings. ; ; For example, to make a procedure that quotes special HTML characters, ; do ; (make-char-quotator ; '((#\< . "<") (#\> . ">") (#\& . "&") (#\" . """))) (define (make-char-quotator char-encoding) (let ((bad-chars (map car char-encoding))) ; Check to see if str contains one of the characters in charset, ; from the position i onward. If so, return that character's index. ; otherwise, return #f (define (index-cset str i charset) (let loop ((i i)) (and (< i (string-length str)) (if (memv (string-ref str i) charset) i (loop (inc i)))))) ; The body of the function (lambda (str) (let ((bad-pos (index-cset str 0 bad-chars))) (if (not bad-pos) str ; str had all good chars (let loop ((from 0) (to bad-pos)) (cond ((>= from (string-length str)) '()) ((not to) (cons (substring str from (string-length str)) '())) (else (let ((quoted-char (cdr (assv (string-ref str to) char-encoding))) (new-to (index-cset str (inc to) bad-chars))) (if (< from to) (cons (substring str from to) (cons quoted-char (loop (inc to) new-to))) (cons quoted-char (loop (inc to) new-to)))))))))) )) |