3 ms·
I've been using SXML [0] for all my sgml needs in Racket and the quality of life improvement from having a sane and regular syntax for everything is hard to ove
by tgbugs 7y ago
I've been using SXML [0] for all my sgml needs in Racket and the quality of life improvement from having a sane and regular syntax for everything is hard to overstate. seml looks like it might have the same kind of quality of life improvements for some of my elisp-only code. I'm not sold on the way that missing attributes are handled using nil, that seems like a design decision that was made to simplify parsing at the expense of making the representation more cluttered.
https://docs.racket-lang.org/sxml/ https://docs.racket-lang.org/sxml/
- neilv 7y agoMy old Scheme/Racket permissive HTML parser[0] initially used what might've been exactly this SEML format. Because it's perhaps the most natural choice for a Lisp person -- HTML element is a list, item 0 of that list is a symbol for the HTML element name, item 1 is an alist of HTML attributes, tail items are HTML element content. However, I changed the format when I saw Oleg Kiselyov's SXML work, to make my Web-scraping and other tools able to use his XML tools. I later made a few other tools that used SXML, such as a simple HTML-writing template embedded in Racket that does some of the checking and work at compilation time.[1] At a library level, SXML's arbitrary nested lists make some things computationally harder to do (e.g., find all the attributes, depending on the "normal form" of SXML), but some other things easier to do (e.g., some kinds of functional editing, due to arbitrary nested lists). Aside from those considerations, SXML is the closest to a de facto standard for XML and HTML tools in Scheme. If I ever happen to have funding to do so, I'd like to revisit the exact representations, to try come up with an end-all-be-all for all purposes, and redesign/reimplement all the tools from scratch. Until then, there's SXML. [0] https://www.neilvandyke.org/racket/html-parsing/ https://www.neilvandyke.org/racket/html-parsing/ [1] https://www.neilvandyke.org/racket/html-template/ https://www.neilvandyke.org/racket/html-template/
- noir_lord 7y agoAlthough different I got a similar quality of life from using pug for html, one you get used to it it's faster to write but crucially much easier to read, it makes the intent so much clearer.
- agumonkey 7y agoIt's funny how the lisp/fp often remove irregularity, at the cost of abstraction [0], which makes people pulling their hair off to the point of going back to simpler but irregular separate logical tools. Even if they complain about it very .. regularly. [0] some people can't bear lisp uniformity for instance.
- chriswarbo 7y agoKeep in mind that Lisp (including SXML) can be written in many ways (parenthesised, indentation based, braces, infixed, prefixed, etc.), which can be mixed and matched within the same expression, and can be trivially converted between automatically. I bring this up so often that I have a go-to blog post for it: http://chriswarbo.net/blog/2017-08-29-s_expressions.html http://chriswarbo.net/blog/2017-08-29-s_expressions.html