diff options
Diffstat (limited to 'hnreader.el')
-rw-r--r-- | hnreader.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/hnreader.el b/hnreader.el index 08bc33a..d5190e8 100644 --- a/hnreader.el +++ b/hnreader.el @@ -286,9 +286,25 @@ third one is 80.") "Return user who wrote this COMMENT-DOM." (dom-text (dom-by-class comment-dom "^hnuser$"))) +(defun hnreader--it-to-it (it) + "Map node to node. +IT is an element in the DOM tree. Map to different IT when it is +a, img or pre. Othewise just copy" + (cond + ((and (listp it) + (listp (cdr it))) ;; check for list but not cons + (cond + ((and (equal (car it) 'a) + (not (dom-by-tag it 'img))) ;; bail out if img + ;; (dom-attr it 'href) + `(span nil ,(dom-attr it 'href))) + (t (mapcar #'hnreader--it-to-it it)))) + (t it))) + (defun hnreader--get-comment (comment-dom) "Get comment dom from COMMENT-DOM." - (dom-by-class comment-dom "^commtext")) + ;; (dom-by-class comment-dom "^commtext")) + (hnreader--it-to-it (dom-by-class comment-dom "^commtext"))) (defun hnreader-readpage-promise (url) "Promise HN URL." |