aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGia Thanh Vuong <thanhvg@gmail.com>2019-08-29 15:05:41 -0600
committerGia Thanh Vuong <thanhvg@gmail.com>2019-08-29 15:05:41 -0600
commita085abf870d630f50e2fc0b76ee90695481e8fb4 (patch)
treef8db275252cd93860cfbb91caabf33a49ebaa4b4
parent1817c5a3e7ac90483ea289d5c2aed1b4c04979f2 (diff)
render cut off links
-rw-r--r--TODOs.org8
-rw-r--r--hnreader.el18
2 files changed, 25 insertions, 1 deletions
diff --git a/TODOs.org b/TODOs.org
index 1b47780..75785de 100644
--- a/TODOs.org
+++ b/TODOs.org
@@ -84,6 +84,14 @@ Assuming the current buffer is an org-mode buffer, the following code collects p
#+end_example
In an org buffer, (org-element-parse-buffer) returns the parse tree of the current buffer. And you can map over it with org-element-map.
+
+with the org buffer, run through it find the text prop of htmlize-link
+
+or hack shr insert link
+
+or a simple way chec in dom for a link and change it
+downside is speed, no we need to iterate and look for a tag and then mutate it, the push it back to the dom. Since the dom is a list
+you need to map the whole dom
* DONE first run on comment buffer won't have right width
also need to shadow shr-use-fonts to nil
* DONE display OP post ins ask and OP infor
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."