Changeset 40377 in project


Ignore:
Timestamp:
08/22/21 21:17:19 (5 weeks ago)
Author:
Jim Ursetto
Message:

svnwiki-sxml: No longer require blank lines in PRE blocks to be indented

Location:
release/5/svnwiki-sxml/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/svnwiki-sxml/trunk/svnwiki-sxml.scm

    r38325 r40377  
    1313(import (only (chicken string) string-intersperse string-split
    1414              string-translate*))
     15(import (only srfi-1 make-list))
    1516(import (only srfi-13 string-trim string-trim-right string-trim-both
    1617              string-concatenate-reverse string-index))
     
    502503  `(pre ,(slurp-preformatted)))
    503504(define (slurp-preformatted)
    504   (let loop ((lines '()))
     505  (let loop ((lines '())
     506             (blank-lines 0))
    505507    (let ((line (peek-buffered-line)))
    506       (cond ((or (eof-object? line)
    507                  (string=? line ""))
     508      (cond ((eof-object? line)
    508509             (discard-line)
    509510             (string-intersperse (reverse lines) "\n"))
     511            ((string=? line "")
     512             (discard-line)
     513             (loop lines (+ 1 blank-lines)))
    510514            ((string-match re:preformatted line)
    511515             => (match-lambda ((_ text)
    512516                          (discard-line)
    513                           (loop (cons text lines)))))
     517                          (loop (cons text (append (make-list blank-lines "")
     518                                                   lines))
     519                                0))))
    514520            (else
    515521             (string-intersperse (reverse lines) "\n"))))))
  • release/5/svnwiki-sxml/trunk/tests/run.scm

    r38325 r40377  
    2424(test-end "Links")
    2525
     26(test-begin "Preformatted blocks")
     27(test '((pre "foo\nbar\nbaz")) (->sxml " foo\n bar\n baz"))
     28(test '((pre "foo\nbar\nbaz\n\nqux\nquux")) (->sxml " foo\n bar\n baz\n \n qux\n quux"))
     29(test '((pre "foo\nbar\nbaz\n\nqux\nquux")) (->sxml " foo\n bar\n baz\n\n qux\n quux"))
     30(test '((pre "foo\nbar\nbaz\n\n\nqux\nquux")) (->sxml " foo\n bar\n baz\n\n\n qux\n quux"))
     31(test-end "Preformatted blocks")
     32
    2633(test-exit)
Note: See TracChangeset for help on using the changeset viewer.