anchor.diff:  (in-package #:cl-markdown)
   
   #|
  +To do:
  +
  +- allow footnotes to appear on a completely separate page
  +- do footnotes as a popup window with mouse over
  +- handle footnotes 'out of band' a la links
  +
   Footnotes
   {note foo}
   {note "This is a note"}
   {note "Foo"}
   {note This is a note}
  -
  - [foo]> This is the note that goes with foo
  -
  -That is what he thought.{footnote foo}
  -
  - [foo]> "This is a longer note with 
  -linefeeds, *mark-up*, and \\\"escaped\\\" quotes.
  -I'll be wicked surprised if it works out of the 
  -box."
   
   (markdown
    "That is what he thought.{footnote foo}
  
positive.code: 4. add footnote text at bottom of document / separate page
  5. add link back to anchor in footnote
  
  |#
  
  
  (defclass* footnote-text ()
    ((id nil ia)
     (text nil ia)))
  
  (defun footnote (phase args result)
    ;; {documentation text}
    (declare (ignore result))
    (when (eq phase :parse)
      (let ((text (format nil "~{~a ~}" args)))
        (when text
  	(format *output-stream* "~&<div class=\"documentation ~(~a~)\">" type)
  	(markdown docs
  		  :stream *output-stream*
  		  :format *current-format*)
  	(format *output-stream* "~&</div>"))
  
      
      (print args)))
  
  (markdown 
   "That's right.{footnote Actually, it isn't, **but**
   that is how it goes.}"
   :additional-extensions '(footnote))
  
  (markdown 
   "That's right.{footnote \"Actually, it isn't, but that is how it goes.\"}"
   :additional-extensions '(footnote))
  
      (bind (((thing &optional type) args)
  	   (thing (let ((*package* (or (docs-package) *package*)))
  		    (with-input-from-string (in thing) (read in))))
  	   (type (or (and type 
  			  (with-input-from-string (in type) (read in)))
  		     (loop for type in '(function variable package setf
  					      type structure compiler-macro
  					      method-combination t)
  			       when (documentation thing type) do
  			       (return type))))
  	   (docs (documentation thing type)))
        (when docs
  	(format *output-stream* "~&<div class=\"documentation ~(~a~)\">" type)
  	(markdown docs
  		  :stream *output-stream*
  		  :format *current-format*)
  	(format *output-stream* "~&</div>"))
        nil)))
  
  
  ;; not yet
  #|
  
negative.code:   (scan #.(ppcre:create-scanner '(:sequence footnote-text)) line))
  
  (define-parse-tree-synonym
    footnote-label
      (:sequence
       :start-anchor
       (:greedy-repetition 0 3 :whitespace-char-class)
  