Sun Jul 3 08:25:45 UTC 2011 pix@kepibu.org * Add support for XMLS-style lists, conflicting with LHTML-style lists Sun Jul 3 07:55:18 UTC 2011 pix@kepibu.org * Minimal support for attribute-starts-with selector Sun Jun 5 21:44:21 UTC 2011 pix@kepibu.org * Update notes file Tue Apr 5 00:14:51 UTC 2011 pix@kepibu.org * depend-on cl-unification-lib to work with stock cl-unification Wed Feb 10 08:50:16 UTC 2010 pix@kepibu.org * Add attribute-equal selector Wed Feb 10 08:28:34 UTC 2010 pix@kepibu.org * Add attribute-present selector Wed Feb 10 08:27:56 UTC 2010 pix@kepibu.org * Serialize returned tags so it's easier to see what was returned Wed Feb 10 08:26:34 UTC 2010 pix@kepibu.org * Formatting. Wed Feb 10 08:26:25 UTC 2010 pix@kepibu.org * Use named-readtables instead of set-dispatch-macro-character Wed Feb 10 08:20:45 UTC 2010 pix@kepibu.org * Return NIL if attribute was not present Sun Feb 7 09:21:16 UTC 2010 pix@kepibu.org * Update notes to reflect updates to cl-unification. Mon Jan 4 07:11:36 UTC 2010 pix@kepibu.org * element-parent now works in lhtml Mon Jan 4 07:06:50 UTC 2010 pix@kepibu.org * Support for asking about ancestors under lhtml Mon Jan 4 06:58:51 UTC 2010 pix@kepibu.org * Don't need &allow-other-key here Mon Jan 4 06:36:34 UTC 2010 pix@kepibu.org * Don't count an+b|b|odd|even as separate items Mon Jan 4 06:32:27 UTC 2010 pix@kepibu.org * :empty selector Mon Jan 4 06:32:07 UTC 2010 pix@kepibu.org * Add *of-type selectors Mon Jan 4 05:59:48 UTC 2010 pix@kepibu.org * "lispier" regexps, l*last-child stuff Probably against best practices to commit monolithic patches, but this is still an unreleased library, so I don't care. Not really sure I care for the sexp-based regexps, but they do make it easy to use the same regexp bits across several places, and I don't have a lexer/parser handy, so they'll have to do for now. Mon Jan 4 01:07:02 UTC 2010 pix@kepibu.org * subject-p makes more sense as (selector, element) For future reference, I used the following code to do this automatically, plus a few minor manual edits (e.g., swapping rcurry and curry): (defun seek-forward (term) (let ((p (search-forward term nil t))) (when p (goto-char p)))) (defun swap-args () (interactive) (save-excursion (while (seek-forward "defmethod subject-p (") (forward-sexp) (transpose-sexps 1))) (save-excursion (while (seek-forward "(subject-p") (forward-sexp) (transpose-sexps 1)))) Mon Jan 4 01:04:12 UTC 2010 pix@kepibu.org * Bring element-matches-p more in line with CSS terms as subject-p Mon Jan 4 01:03:10 UTC 2010 pix@kepibu.org * Make subjects-of use subjects-in-list Mon Jan 4 00:11:25 UTC 2010 pix@kepibu.org * Rename some functions to better match CSS terminology Sat Jan 2 09:45:37 UTC 2010 pix@kepibu.org * Add fixme Sat Jan 2 08:38:38 UTC 2010 pix@kepibu.org * &allow-other-keys is not actually necessary Fri Jan 1 05:06:19 UTC 2010 pix@kepibu.org * Patch went in to cl-unification, so no longer need warning Mon Dec 28 10:00:30 UTC 2009 pix@kepibu.org * Another nth-last-child Mon Dec 28 09:59:18 UTC 2009 pix@kepibu.org * Minor syntactic changes To make more modern org-modes happy. Woo. Sun Dec 20 08:23:57 UTC 2009 pix@kepibu.org * Update notes Sun Dec 13 07:28:56 UTC 2009 pix@kepibu.org * Export xml, too Sun Dec 13 05:32:46 UTC 2009 pix@kepibu.org * Add some notes Sun Dec 13 05:24:52 UTC 2009 pix@kepibu.org * Add element-content as a prereq to matching on an element's textual content Sun Dec 13 05:23:23 UTC 2009 pix@kepibu.org * Ugly unbreaking of lhtml--man I hate this bit Sat Dec 5 07:23:38 UTC 2009 pix@kepibu.org * Better method to do this in Sat Dec 5 07:18:05 UTC 2009 pix@kepibu.org * implicit-element is a better name than root Also add a bit of support for sibling combinators when dealing with the implicit element, and note a problem that crops up when dealing with selections on a non-root element (should a simple-selector select the element, or is there an implicit descendant combinator?). Fri Dec 4 05:16:28 UTC 2009 pix@kepibu.org * Fix an odd clisp compile issue Fri Dec 4 04:47:58 UTC 2009 pix@kepibu.org * Make descendant combinators work with an implicit parent Thu Dec 3 03:26:59 UTC 2009 pix@kepibu.org * declare ignored variables Thu Dec 3 02:41:36 UTC 2009 pix@kepibu.org * Better messages Thu Dec 3 00:12:02 UTC 2009 pix@kepibu.org * Add sibling and adjacent combinators Thu Dec 3 00:07:44 UTC 2009 pix@kepibu.org * Fix copy-paste issue. Mon Nov 30 05:04:24 UTC 2009 pix@kepibu.org * Record idea Mon Nov 30 05:04:06 UTC 2009 pix@kepibu.org * Work for spaces between [+-] and B Mon Nov 30 04:48:22 UTC 2009 pix@kepibu.org * Combine nth-child variants Mon Nov 30 04:10:09 UTC 2009 pix@kepibu.org * Fix bug in element-children for sgml:pt model Mon Nov 30 04:09:10 UTC 2009 pix@kepibu.org * Add :nth-child selector Mon Nov 23 13:25:26 UTC 2009 pix@kepibu.org * Whoops Mon Nov 23 13:19:59 UTC 2009 pix@kepibu.org * Fail unification if no match for a selector Mon Nov 23 13:14:45 UTC 2009 pix@kepibu.org * add FIXME test Mon Nov 23 13:14:00 UTC 2009 pix@kepibu.org * Error when unable to parse CSS selector Mon Nov 23 13:13:22 UTC 2009 pix@kepibu.org * Start documentation Mon Nov 23 13:02:12 UTC 2009 pix@kepibu.org * Import when-let*, too Mon Nov 23 13:01:50 UTC 2009 pix@kepibu.org * Indentation Mon Nov 23 11:54:01 UTC 2009 pix@kepibu.org * Cut out a few warnings from cl-unification Mon Nov 23 11:38:12 UTC 2009 pix@kepibu.org * No longer needed Mon Nov 23 11:36:20 UTC 2009 pix@kepibu.org * Don't return a dom:document as parent Mon Nov 23 11:33:15 UTC 2009 pix@kepibu.org * :first-child and :nth-child(n) selectors Mon Nov 23 10:24:02 UTC 2009 pix@kepibu.org * Status commit; fix unification Sat Nov 21 18:31:09 UTC 2009 pix@kepibu.org * Tired, probably doing stupid things Sat Nov 21 16:12:13 UTC 2009 pix@kepibu.org * Status commit Fri Nov 20 13:09:18 UTC 2009 pix@kepibu.org * Add fixme Thu Nov 19 06:25:36 UTC 2009 pix@kepibu.org * Moar CSS selectors, fewer explicit lambdas Wed Nov 18 10:25:48 UTC 2009 pix@kepibu.org * Try to set a sensible default for *default-parser* Wed Nov 18 10:23:22 UTC 2009 pix@kepibu.org * Add notes file Wed Nov 18 10:23:05 UTC 2009 pix@kepibu.org * Status commit; split to avoid absolute dependency on cxml and closure-html Wed Nov 18 08:57:44 UTC 2009 pix@kepibu.org * status commit; add cxml:dom support diff -rN -u old-Oh, Ducks!/chtml.lisp new-Oh, Ducks!/chtml.lisp --- old-Oh, Ducks!/chtml.lisp 1970-01-01 00:00:00.000000000 +0000 +++ new-Oh, Ducks!/chtml.lisp 2013-08-04 15:26:16.000000000 +0000 @@ -0,0 +1,24 @@ +(in-package #:oh-ducks) + +;; avoid conflicting with 'sgml:pt +(eval-when (:compile-toplevel :load-toplevel :execute) + (import 'closure-html:pt)) +(eval-when (:compile-toplevel :load-toplevel :execute) + (export 'pt) + (export 'lhtml)) + +(defclass html-template (css-selector-template) ()) + +(add-handler 'pt 'chtml:make-pt-builder) +(add-handler 'lhtml 'chtml:make-lhtml-builder) + +(unless *default-parser* + (setf *default-parser* (rcurry #'chtml:parse (get-handler-for-model 'pt)))) + +(defmethod make-template ((kind (eql 'html)) (spec cons)) + (destructuring-bind (&key parser model) + (append (when (%spec-includes-opts spec) (second spec)) + (list :model 'pt)) + (make-instance 'html-template + :parser (or parser (rcurry #'chtml:parse (get-handler-for-model model))) + :spec spec))) diff -rN -u old-Oh, Ducks!/cxml.lisp new-Oh, Ducks!/cxml.lisp --- old-Oh, Ducks!/cxml.lisp 1970-01-01 00:00:00.000000000 +0000 +++ new-Oh, Ducks!/cxml.lisp 2013-08-04 15:26:16.000000000 +0000 @@ -0,0 +1,20 @@ +(in-package #:oh-ducks) + +(eval-when (:compile-toplevel :load-toplevel :execute) + (export 'dom) + (export 'xml)) + +(defclass xml-template (css-selector-template) ()) + +(add-handler 'dom 'cxml-dom:make-dom-builder) + +(unless *default-parser* + (setf *default-parser* (rcurry #'cxml:parse (get-handler-for-model 'dom)))) + +(defmethod make-template ((kind (eql 'xml)) (spec cons)) + (destructuring-bind (&key parser model) + (append (when (%spec-includes-opts spec) (second spec)) + (list :model 'dom)) + (make-instance 'xml-template + :parser (or parser (rcurry #'cxml:parse (get-handler-for-model model))) + :spec spec))) diff -rN -u old-Oh, Ducks!/notes new-Oh, Ducks!/notes --- old-Oh, Ducks!/notes 1970-01-01 00:00:00.000000000 +0000 +++ new-Oh, Ducks!/notes 2013-08-04 15:26:16.000000000 +0000 @@ -0,0 +1,197 @@ +#-*-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 := ( . ) | + ( .