;;;; (texinfo) -- parsing of texinfo into SXML
;;;;
-;;;; Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+;;;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
;;;; Copyright (C) 2004, 2009 Andy Wingo <wingo at pobox dot com>
;;;; Copyright (C) 2001,2002 Oleg Kiselyov <oleg at pobox dot com>
;;;;
(sample INLINE-TEXT)
(samp INLINE-TEXT)
(code INLINE-TEXT)
+ (math INLINE-TEXT)
(kbd INLINE-TEXT)
(key INLINE-TEXT)
(var INLINE-TEXT)
(value INLINE-ARGS . (key))
(ref INLINE-ARGS . (node #:opt name section info-file manual))
(xref INLINE-ARGS . (node #:opt name section info-file manual))
- (pxref INLINE-ARGS . (node #:opt name section info-file manual))
+ (pxref INLINE-TEXT-ARGS
+ . (node #:opt name section info-file manual))
(url ALIAS . uref)
- (uref INLINE-ARGS . (url #:opt title replacement))
+ (uref INLINE-TEXT-ARGS . (url #:opt title replacement))
(anchor INLINE-ARGS . (name))
(dots INLINE-ARGS . ())
(result INLINE-ARGS . ())
;; Like a DTD for texinfo
(define (command-spec command)
- (or (assq command texi-command-specs)
- (parser-error #f "Unknown command" command)))
+ (let ((spec (assq command texi-command-specs)))
+ (cond
+ ((not spec)
+ (parser-error #f "Unknown command" command))
+ ((eq? (cadr spec) 'ALIAS)
+ (command-spec (cddr spec)))
+ (else
+ spec))))
(define (inline-content? content)
(case content
(assert-curr-char '(#\@) "start of the command" port)
(let ((peeked (peek-char port)))
(cond
- ((memq peeked '(#\! #\. #\? #\@ #\\ #\{ #\}))
+ ((memq peeked '(#\! #\: #\. #\? #\@ #\\ #\{ #\}))
;; @-commands that escape characters
(make-token 'STRING (string (read-char port))))
(else
(arguments->attlist port (read-arguments port stop-char) arg-names))
(let* ((spec (command-spec command))
+ (command (car spec))
(type (cadr spec))
(arg-names (cddr spec)))
(case type
- ((ALIAS)
- (complete-start-command arg-names port))
((INLINE-TEXT)
(assert-curr-char '(#\{) "Inline element lacks {" port)
(values command '() type))
(let* ((token (read-command-token port))
(end? (eq? (token-kind token) 'END)))
(values
- (handle str-handler fragment (if end? "" " ") seed)
+ (handle str-handler fragment
+ (if end? "" (if preserve-ws? "\n" " "))
+ seed)
token)))
((and (not preserve-ws?) (eq? c #\newline))
;; paragraph-separator ::= #\newline #\newline+
(loop port expect-eof? end-para need-break? seed)))
((START) ; Start of an @-command
(let* ((head (token-head token))
- (type (cadr (command-spec head)))
+ (spec (command-spec head))
+ (head (car spec))
+ (type (cadr spec))
(inline? (inline-content? type))
(seed ((if (and inline? (not need-break?))
identity end-para) seed))
(lambda (command args content seed) ; fdown
'())
(lambda (command args parent-seed seed) ; fup
- (let ((seed (reverse-collect-str-drop-ws seed))
- (spec (command-spec command)))
+ (let* ((seed (reverse-collect-str-drop-ws seed))
+ (spec (command-spec command))
+ (command (car spec)))
(if (eq? (cadr spec) 'INLINE-TEXT-ARGS)
(cons (list command (cons '% (parse-inline-text-args #f spec seed)))
parent-seed)
(let ((parser (make-dom-parser)))
;; duplicate arguments->attlist to avoid unnecessary splitting
(lambda (command port)
- (let ((args (cdar (parser '*ENVIRON-ARGS* port '())))
- (arg-names (cddr (command-spec command))))
+ (let* ((args (cdar (parser '*ENVIRON-ARGS* port '())))
+ (spec (command-spec command))
+ (command (car spec))
+ (arg-names (cddr spec)))
(cond
((not arg-names)
(if (null? args) '()