#-*-mode: org;-*- * Purpose "Oh, Ducks!" is an extension to cl-unification to make parsing structured documents easy, using CSS selectors. * Installation ** Prerequisites + cl-unification + cl-ppcre + split-sequence + alexandria + asdf-system-connections * closure-html * cxml * named-readtables [+] Mandatory [*] Optional ** Loading Loading "Oh, Ducks!" is just like loading any other ASDF system. However, because it does not mandate a particular HTML or XML parser, it does not generally become useful until you have also loaded an HTML/XML parsing library such as cxml or closure-html. Start with: : (asdf:oos 'asdf:load-op :oh-ducks) If you would like to use the built-in support for parsing via closure-html (which you almost certainly do), you'll also want to load closure-html: : (asdf:oos 'asdf:load-op :closure-html) And, if you want to use DOM objects provided by cxml: : (asdf:oos 'asdf:load-op :cxml) ** Load-order Caveats closure-html and cl-unification each define competing readers on #t. To avoid load-order issues resulting in an indeterminate reader on #t, you'll probably want to add : #.(set-dispatch-macro-character #\# #\T 'unify::|sharp-T-reader|) or : (unify:enable-template-reader) or : (named-readtables:in-readtable unify:template-readtable) to the top of any file which uses cl-unification's reader templates. (The latter two currently only work if you have cl-unification from my darcs repo.) Please feel free to submit patches to closure-html and cl-unification to fix this problem. ** Depending Upon in ASDF Systems It doesn't take long before managing your dependencies upon ASDF systems becomes easiest by creating an ASDF system for whatever project you're currently engaged in. It's important to note that, in addition to depending upon oh-ducks, you'll also want to depend upon whichever library provides your desired object model and parser. For example, : :depends-on (:oh-ducks :closure-html :cxml) ** Differentiating between LHTML lists and XMLS lists While it would, in theory, be possible to inspect lists and determine if they are LHTML or XMLS lists, this is not currently done. You can, however, choose which type you'd like to work with by pushing =:lists-are-xmls= or =:lists-are-lhtml= to =*features*= before loading "Oh, Ducks!". Unfortunately, this means you can only expect to use one list type in a single lisp image. Patches to either automagically detect the list type, or to provide layered functions are welcome. * Usage The combination of oh-ducks and closure-html provides an HTML template for use with cl-unification, and has the following syntax: (match (#t(html [(:model )] +) ) &body) selectors := ( . ) | ( .