anchor.diff:  (defun generate-html (file)
     "Generate HTML for the markup file in the same location except with an .html
   extension."
  -  (with-output-to-file (out (make-pathname :type "html" :defaults file))
  -    (monkeylib-text-output:with-text-output (out)
  -      (monkeylib-html:emit-html
  -       (markup-html
  -        (markup (file-text file))))))
  +  (let ((*default-pathname-defaults* (parent-directory file)))
  +    (with-output-to-file (out (make-pathname :type "html" :defaults file))
  +      (monkeylib-text-output:with-text-output (out)
  +        (monkeylib-html:emit-html
  +         (markup-html
  +          (markup (file-text file)))))))
     t)
   
   (defun markup-html (doc &key title (style "style.css") script)
  -  (funcall
  -   (>>>
  -    #'links
  -    #'endnotes
  -    (rewriter :img #'image)
  -    (rewriter-if #'formatted-code-section #'formatted-code)
  -    #'htmlize
  -    (entitle title)
  -    (stylize style)
  -    (enscript script)
  -    (rewriter :section-marker #'divver)
  -    (rewriter :section #'section-to-div)
  -    )
  -   doc))
  +  (let ((has-tweets (extract :tweet doc)))
  +    (funcall
  +     (>>>
  +      #'links
  +      #'endnotes
  +      (rewriter :section #'(lambda (x) (if (eql (car (second x)) :tweet) (tweet-by-id (second x)) x)))
  +      (rewriter :section #'(lambda (x) (if (eql (car (second x)) :javascript) (script (second x)) x)))
  +      (rewriter :section #'(lambda (x) (if (eql (car (second x)) :chart) (chart (second x)) x)))
  +      (rewriter :section (if-is-section :include #'include-from-file))
  +      (rewriter :img #'image)
  +      (rewriter-if #'formatted-code-section #'formatted-code)
  +      #'htmlize
  +      (entitle title)
  +      (stylize style)
  +      (enscript script)
  +      (enscript "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML" :where :head :async t)
  +      (twitter-widget has-tweets)
  +      (rewriter :section-marker #'section-marker)
  +      (rewriter :section #'section-to-div)
  +      )
  +     doc)))
  +
  +(defun if-is-section (tag fn)
  +  #'(lambda (tree)
  +      (if (eql (car (second tree)) tag)
  +          (funcall fn (second tree))
  +          tree)))
  +
   
   (defun links (doc)
     "Rewrite the doc so :link elements are expanded into :a tags with the
  
positive.code:   (destructuring-bind (section (formattedcode (pre text))) expr
      (declare (ignore section formattedcode pre))
      `(:pre ,@(nth-value 1 (markup-lite (cons text 0))))))
  
negative.code:                   `((:style (:noescape ,style)))
                    `((:link :href ,style :rel "stylesheet"))))))
  
  (defun enscript (script &key (where :body) (async nil))
    "Add an SCRIPT tag if script is provided."
    (if script
        (rewriter where (appending `((:script ,@(if async '(:async "async")) :src ,script :type "text/javascript"))))
        #'identity))
  
  (defun script (script)
    `(:script
      :src ,(just-text script)
      :type "text/javascript"
      :charset "utf-8"))
  
  (defun script/async (script)
    `(:script
      :async "async"
      :src ,(just-text script)
      :type "text/javascript"
      :charset "utf-8"))
  
  (defun twitter-widget (has-tweets)
    (if has-tweets
        (rewriter :body (appending (list (script/async "https://platform.twitter.com/widgets.js"))))
        #'identity))
  
  (defun section-marker (x)
    (declare (ignore x))
    `(:hr :class "fleuron"))
  
  ;;; Helper functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  