rst.lisp: Generate the BODY of the HTML document
This commit is contained in:
parent
678ea7fe4a
commit
a856f0284d
1 changed files with 16 additions and 6 deletions
|
@ -5,18 +5,28 @@
|
|||
(:use :cl)
|
||||
(:import-from :coleslaw #:render-text)
|
||||
(:import-from :docutils #:read-rst #:write-part #:register-settings-spec
|
||||
#:visit-node #:write-document)
|
||||
(:import-from :docutils.writer.html #:html-writer)
|
||||
#:visit-node #:write-document #:document)
|
||||
(:import-from :docutils.writer.html #:html-writer
|
||||
#:body-pre-docinfo
|
||||
#:body
|
||||
#:parts)
|
||||
(:export #:enable))
|
||||
|
||||
(in-package :coleslaw-rst)
|
||||
|
||||
;; XXX: This is not an ideal solution as it affects other uses of docutils in
|
||||
;; the same lisp image.
|
||||
(defmethod visit-node :after ((writer html-writer) (document document))
|
||||
"This method removes unnecessary HTML elements, such as html, head, body
|
||||
and make docutils output only html fragment with document itself."
|
||||
(setf (slot-value writer 'parts) '(body-pre-docinfo
|
||||
body)))
|
||||
|
||||
(defmethod render-text (text (format (eql :rst)))
|
||||
(register-settings-spec '((:generator nil)
|
||||
(:datestamp nil)))
|
||||
(with-output-to-string (str)
|
||||
(let ((writer (make-instance 'html-writer))
|
||||
(document (read-rst text)))
|
||||
(write-document writer document str))))
|
||||
(write-document writer document 'string)))
|
||||
|
||||
(defun enable ())
|
||||
|
|
Loading…
Add table
Reference in a new issue