greghendershott / markdown

Markdown parser written in Racket.
101 stars 28 forks source link

observe `xexpr-drop-empty-attributes`? #61

Closed mbutterick closed 8 years ago

mbutterick commented 8 years ago

The xexpr-drop-empty-attributes parameter in xml/xexpr controls whether empty attribute lists are omitted from X-expressions.

parse-markdown makes X-expressions, but does not observe this parameter. Can it? Should it?

(parameterize ([xexpr-drop-empty-attributes #t])
  (parse-markdown "I am _emph_ and I am **strong**."))

> '((p () "I am " (em () "emph") " and I am " (strong () "strong") "."))

;; vs. '((p "I am " (em "emph") " and I am " (strong "strong") "."))
mbutterick commented 8 years ago

(PS Obviously stripping the attributes afterwards is simple. This issue should not be mistaken for anything serious.)

greghendershott commented 8 years ago

It's a good question. I have mixed feelings about xexpr attributes being optional. That's convenient when typing xexprs by hand. OTOH when consuming xexprs, it's more convenient if they're always normalized to include an attribute list. A client of this package doesn't need to handle them being optional. So I think the status quo is a plus?

mbutterick commented 8 years ago

Fair enough. For Pollen I considered both options. I ended up going the opposite way (= no empty attr lists) because most tags don't have attributes, and the annoyance (to humans) of the extra housekeeping seemed to outweigh the benefits (to machines) of having them. Still, truly minor.