mirror of https://codeberg.org/cage/tinmop/
- prevented adding a quote prefix to each element inside a blockquote tag, when converting html to text.
This commit is contained in:
parent
a2c7c1d581
commit
d01b6c798f
|
@ -102,6 +102,8 @@
|
||||||
|
|
||||||
(defparameter *prefix-text-line* "")
|
(defparameter *prefix-text-line* "")
|
||||||
|
|
||||||
|
(defparameter *block-tag* nil)
|
||||||
|
|
||||||
(defun html->text (html &key
|
(defun html->text (html &key
|
||||||
(add-link-footnotes t) (body-footnotes-separator "")
|
(add-link-footnotes t) (body-footnotes-separator "")
|
||||||
(quote-prefix "> ") (list-item-prefix "* "))
|
(quote-prefix "> ") (list-item-prefix "* "))
|
||||||
|
@ -130,11 +132,14 @@ Some convenience functions are provided to works with these structures.
|
||||||
(when node
|
(when node
|
||||||
(cond
|
(cond
|
||||||
((stringp node)
|
((stringp node)
|
||||||
(princ (strcat *prefix-text-line* node) body-stream))
|
(if *block-tag*
|
||||||
|
(princ (strcat *prefix-text-line* node) body-stream)
|
||||||
|
(princ node body-stream)))
|
||||||
((consp (car node))
|
((consp (car node))
|
||||||
(descend (car node)))
|
(descend (car node)))
|
||||||
((tag= +tag-link+ node)
|
((tag= +tag-link+ node)
|
||||||
(let ((link (find-attribute +attribute-url+ node)))
|
(let ((*block-tag* nil)
|
||||||
|
(link (find-attribute +attribute-url+ node)))
|
||||||
(incf link-count)
|
(incf link-count)
|
||||||
(if link
|
(if link
|
||||||
(format footnotes-stream
|
(format footnotes-stream
|
||||||
|
@ -149,20 +154,25 @@ Some convenience functions are provided to works with these structures.
|
||||||
(when add-link-footnotes
|
(when add-link-footnotes
|
||||||
(format body-stream " [~a] " link-count))))
|
(format body-stream " [~a] " link-count))))
|
||||||
((tag= +tag-break+ node)
|
((tag= +tag-break+ node)
|
||||||
(format body-stream "~%")
|
(let ((*block-tag* nil))
|
||||||
(descend-children node))
|
(format body-stream "~%")
|
||||||
|
(descend-children node)))
|
||||||
((or (tag= +tag-paragraph+ node)
|
((or (tag= +tag-paragraph+ node)
|
||||||
(tag= +tag-div+ node))
|
(tag= +tag-div+ node))
|
||||||
(format body-stream "~%")
|
(let ((*block-tag* t))
|
||||||
(descend-children node)
|
(format body-stream "~%")
|
||||||
(format body-stream "~%"))
|
(descend-children node)
|
||||||
|
(format body-stream "~%")))
|
||||||
((tag= +tag-list-item+ node)
|
((tag= +tag-list-item+ node)
|
||||||
(format body-stream list-item-prefix)
|
(let ((*block-tag* nil))
|
||||||
(descend-children node)
|
(format body-stream list-item-prefix)
|
||||||
(format body-stream "~%"))
|
(descend-children node)
|
||||||
|
(format body-stream "~%")))
|
||||||
((tag= +tag-blockquote+ node)
|
((tag= +tag-blockquote+ node)
|
||||||
(let ((*prefix-text-line* quote-prefix))
|
(let ((*prefix-text-line* quote-prefix)
|
||||||
(descend-children node)))
|
(*block-tag* t))
|
||||||
|
(descend-children node)
|
||||||
|
(format body-stream "~%")))
|
||||||
(t
|
(t
|
||||||
(descend-children node))))))
|
(descend-children node))))))
|
||||||
(descend root)
|
(descend root)
|
||||||
|
|
Loading…
Reference in New Issue