You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m toying with making some changes to Punct. They’re not breaking, per se, but the last item may result in behavior you don’t currently expect.
They’re “elements” now
Standardizing on custom elements as the preferred term for tagged X-expressions inserted into the document via escaped Racket code. That last clause distinguishes a custom element from an element produced by the Markdown parser (and from Pollen “tags”). A Punct element may be one of two types of block element (single or root).
New functions for defining custom elements
;; The old way
(define (aside . elems)
`(aside [[block "single"] [class"x"]] ,@elems))
;; Equivalent to the above, but the returned function also allows for arbitrary keyword args as attributes
(define aside
(default-element-function 'aside#:class"x"#:block"single"))
;; Equivalent to the above:
(define aside (default-element-function 'aside.x¶))
;; Equivalent to the above, but more concise:
(define-default-element aside.x¶)
Specifics on the sugar:
Adding, e.g., .clown after the element’s tag will cause the returned function to include (class "clown") in the element’s attribute list.
Suffixing the identifier with ¶ will cause ithe returned function to include (block "single") in the element’s attribute list, ensuring Punct treats it as a block when it appears on its own line. Likewise, suffixing with § will cause it to include(block "root") in its attributes, allowing the element to contain other block elements.
The bound identifier will not include any of these suffixes. I.e., (define-default-element aside.x¶) produces a function bound to aside.
Default functions for unbound identifiers
Similar to pollen/top, Punct will allow you to use unbound identifiers in your sources. Expressions beginning with an unbound identifier will use the result of applying define-default-element to the unbound identifier:
#lang punct
•aside§{Don’t make me wrap this.}
…produces (aside [[class "root"]] "Don’t make me wrap this.").
With this change, you would no longer receive an unbound identifier error at compile time, which may not always be preferred. I may include a parameter that would re-enable the old behavior. Alternately you could catch problems like this at render time by raising an error in the fallback function supplied to, e.g., doc->html.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I’m toying with making some changes to Punct. They’re not breaking, per se, but the last item may result in behavior you don’t currently expect.
They’re “elements” now
Standardizing on custom elements as the preferred term for tagged X-expressions inserted into the document via escaped Racket code. That last clause distinguishes a custom element from an element produced by the Markdown parser (and from Pollen “tags”). A Punct element may be one of two types of block element (single or root).
New functions for defining custom elements
Specifics on the sugar:
.clown
after the element’s tag will cause the returned function to include(class "clown")
in the element’s attribute list.¶
will cause ithe returned function to include(block "single")
in the element’s attribute list, ensuring Punct treats it as a block when it appears on its own line. Likewise, suffixing with§
will cause it to include(block "root")
in its attributes, allowing the element to contain other block elements.(define-default-element aside.x¶)
produces a function bound toaside
.Default functions for unbound identifiers
Similar to
pollen/top
, Punct will allow you to use unbound identifiers in your sources. Expressions beginning with an unbound identifier will use the result of applyingdefine-default-element
to the unbound identifier:…produces
(aside [[class "root"]] "Don’t make me wrap this.")
.With this change, you would no longer receive an unbound identifier error at compile time, which may not always be preferred. I may include a parameter that would re-enable the old behavior. Alternately you could catch problems like this at render time by raising an error in the fallback function supplied to, e.g.,
doc->html
.Beta Was this translation helpful? Give feedback.
All reactions