chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #1291: lowdown: markdown->sxml produces unnormalised


From: Chicken Trac
Subject: [Chicken-janitors] #1291: lowdown: markdown->sxml produces unnormalised SXML
Date: Thu, 26 May 2016 16:51:39 -0000

#1291: lowdown: markdown->sxml produces unnormalised SXML
------------------------+---------------------
 Reporter:  nxg         |      Owner:
     Type:  defect      |     Status:  new
 Priority:  major       |  Milestone:  someday
Component:  extensions  |    Version:  4.10.x
 Keywords:  lowdown     |
------------------------+---------------------
 {{{
 % csi

 CHICKEN
 (c) 2008-2015, The CHICKEN Team
 (c) 2000-2007, Felix L. Winkelmann
 Version 4.10.0 (rev b259631)
 macosx-unix-clang-x86-64 [ 64bit manyargs dload ptables ]
 compiled 2015-08-04 on yves.more-magic.net (Linux)

 #;1> (use lowdown sxpath)
 ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/lowdown.import.so ...
 [...]
 #;2> (define testdoc "Title\n=====\n\n  * [link](uri)\n")
 #;3> (define sx-test (with-input-from-string testdoc (lambda ()
 (markdown->sxml (current-input-port)))))
 #;4> sx-test
 ((h1 ("Title")) (ul (li ((a (@ (href "uri")) "link")))))
 #;5> ((sxpath '(// a)) sx-test)
 ()
 #;6> (define (tidy-sxml sx)
       (cond ((not (list? sx)) sx)
             ((and (= (length sx) 1)
                   (list? (car sx)))
              ;; turn ((node ...)) into (node ...)
              (tidy-sxml (car sx)))
             (else (map tidy-sxml sx))))
 #;7> ((sxpath '(// a)) (tidy-sxml sx-test))
 ((a (@ (href "uri")) "link"))
 #;8>
 }}}

 I think the parsed `sx-test` is not invalid, but it does appear to be
 sufficiently unnormalised that it confuses `sxpath`.
 See http://okmij.org/ftp/Scheme/SXML.html#Normalized%20SXML

 The function `tidy-sxml` works in this case, but is probably too simple-
 minded to work in general.

--
Ticket URL: <http://bugs.call-cc.org/ticket/1291>
CHICKEN Scheme <http://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]