1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

more robust texinfo alias handling

* module/texinfo.scm (command-spec): Resolve aliases here.
  (complete-start-command, make-command-parser):
  (make-dom-parser, parse-environment-args): Reload command after
  resolving spec, so we get the alias target.
This commit is contained in:
Andy Wingo 2012-08-25 11:52:44 +02:00
parent 6c9220064d
commit dc7a9cefbf

View file

@ -384,8 +384,14 @@ Examples:
;; Like a DTD for texinfo ;; Like a DTD for texinfo
(define (command-spec command) (define (command-spec command)
(or (assq command texi-command-specs) (let ((spec (assq command texi-command-specs)))
(parser-error #f "Unknown command" command))) (cond
((not spec)
(parser-error #f "Unknown command" command))
((eq? (cadr spec) 'ALIAS)
(command-spec (cddr spec)))
(else
spec))))
(define (inline-content? content) (define (inline-content? content)
(case content (case content
@ -647,11 +653,10 @@ Examples:
(arguments->attlist port (read-arguments port stop-char) arg-names)) (arguments->attlist port (read-arguments port stop-char) arg-names))
(let* ((spec (command-spec command)) (let* ((spec (command-spec command))
(command (car spec))
(type (cadr spec)) (type (cadr spec))
(arg-names (cddr spec))) (arg-names (cddr spec)))
(case type (case type
((ALIAS)
(complete-start-command arg-names port))
((INLINE-TEXT) ((INLINE-TEXT)
(assert-curr-char '(#\{) "Inline element lacks {" port) (assert-curr-char '(#\{) "Inline element lacks {" port)
(values command '() type)) (values command '() type))
@ -954,7 +959,9 @@ Examples:
(loop port expect-eof? end-para need-break? seed))) (loop port expect-eof? end-para need-break? seed)))
((START) ; Start of an @-command ((START) ; Start of an @-command
(let* ((head (token-head token)) (let* ((head (token-head token))
(type (cadr (command-spec head))) (spec (command-spec head))
(head (car spec))
(type (cadr spec))
(inline? (inline-content? type)) (inline? (inline-content? type))
(seed ((if (and inline? (not need-break?)) (seed ((if (and inline? (not need-break?))
identity end-para) seed)) identity end-para) seed))
@ -1045,8 +1052,9 @@ Examples:
(lambda (command args content seed) ; fdown (lambda (command args content seed) ; fdown
'()) '())
(lambda (command args parent-seed seed) ; fup (lambda (command args parent-seed seed) ; fup
(let ((seed (reverse-collect-str-drop-ws seed)) (let* ((seed (reverse-collect-str-drop-ws seed))
(spec (command-spec command))) (spec (command-spec command))
(command (car spec)))
(if (eq? (cadr spec) 'INLINE-TEXT-ARGS) (if (eq? (cadr spec) 'INLINE-TEXT-ARGS)
(cons (list command (cons '% (parse-inline-text-args #f spec seed))) (cons (list command (cons '% (parse-inline-text-args #f spec seed)))
parent-seed) parent-seed)
@ -1062,8 +1070,10 @@ Examples:
(let ((parser (make-dom-parser))) (let ((parser (make-dom-parser)))
;; duplicate arguments->attlist to avoid unnecessary splitting ;; duplicate arguments->attlist to avoid unnecessary splitting
(lambda (command port) (lambda (command port)
(let ((args (cdar (parser '*ENVIRON-ARGS* port '()))) (let* ((args (cdar (parser '*ENVIRON-ARGS* port '())))
(arg-names (cddr (command-spec command)))) (spec (command-spec command))
(command (car spec))
(arg-names (cddr spec)))
(cond (cond
((not arg-names) ((not arg-names)
(if (null? args) '() (if (null? args) '()