ignore extraneous arguments passed to `meta`

pull/27/head
Matthew Butterick 10 years ago
parent f946883d67
commit e64cde7e51

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -49,7 +49,7 @@
(define (meta-key x) (car (caadr x))) (define (meta-key x) (car (caadr x)))
(define (meta-value x) (cadr (caadr x))) (define (meta-value x) (cadr (caadr x)))
(define is-meta-element? (λ(x) (and (list? x) ; possible txexpr (define is-meta-element? (λ(x) (and (list? x) ; possible txexpr
(= (length x) 2) ; = tag + attribute (>= (length x) 2) ; = tag + attribute + other elements (which are ignored)
(equal? 'meta (car x)) ; tag is 'meta (equal? 'meta (car x)) ; tag is 'meta
(symbol? (meta-key x)) ; attribute key is symbol (symbol? (meta-key x)) ; attribute key is symbol
(string? (meta-value x))))) ; attribute value is string (string? (meta-value x))))) ; attribute value is string

@ -455,7 +455,7 @@ The value of edge is ◊|edge| pixels}
Metas are not a foundational abstraction. They're just a convenience — a place to store arbitrary pieces of information that you might want to use later. Metas are not a foundational abstraction. They're just a convenience — a place to store arbitrary pieces of information that you might want to use later.
@margin-note{Pollen occasionally relies on metas. For instance, the @racket[get-template-for] function will look in the metas of a source file to see if a template is explicitly specified. The @racket[pollen/template] module also contains functions for working with metas, such as @racket[select-from-metas].} @margin-note{Pollen occasionally uses metas. For instance, the @racket[get-template-for] function will look in the metas of a source file to see if a template is explicitly specified. The @racket[pollen/template] module also contains functions for working with metas, such as @racket[select-from-metas].}
To insert a meta, use the standard command syntax for inserting a tag with an attribute pair, but use the special @tt{meta} name: To insert a meta, use the standard command syntax for inserting a tag with an attribute pair, but use the special @tt{meta} name:
@ -475,6 +475,8 @@ When you mark a meta like this, two things happen. First, when you run the file,
'(some-tag ((key "value")) "Another normal tag") '(some-tag ((key "value")) "Another normal tag")
} }
@margin-note{If your @tt{meta} includes a text argument between curly braces — or any other arguments aside from the initial keyvalue pair — they will be ignored.}
Second, the meta is collected into a hash table that is exported with the name @tt{metas}. To see this hash table, run the file above in DrRacket, then move to the interactions window and type @exec{metas} at the prompt: Second, the meta is collected into a hash table that is exported with the name @tt{metas}. To see this hash table, run the file above in DrRacket, then move to the interactions window and type @exec{metas} at the prompt:
@terminal{ @terminal{

Loading…
Cancel
Save