aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGia Thanh Vuong <thanhvg@gmail.com>2019-08-20 13:31:20 -0600
committerGia Thanh Vuong <thanhvg@gmail.com>2019-08-20 13:31:20 -0600
commit76b9aa6576e5bb4ba0e521f82c2009cb8c69efdc (patch)
tree3eb2bc46cb6bb5d683c21e76391d00a1e37c4e51
parente69a573daece1fc7e3f5a4d940a18d3f66b5a0a3 (diff)
sanitize star char in comment, partly
-rw-r--r--TODOs.org3
-rw-r--r--hnreader.el15
2 files changed, 14 insertions, 4 deletions
diff --git a/TODOs.org b/TODOs.org
index ae2d7f9..ec73f77 100644
--- a/TODOs.org
+++ b/TODOs.org
@@ -33,3 +33,6 @@ or recursive on dom will be just fine
* DONE comment page show main link and intro text
* TODO display page takes page number
* TODO reload page
+* TODO frontpage has next page link
+* remove * in text
+find and replace raw htlm '< *' with '< -'
diff --git a/hnreader.el b/hnreader.el
index 5ac7aec..7f54cf8 100644
--- a/hnreader.el
+++ b/hnreader.el
@@ -29,7 +29,11 @@ third one is 80.")
(promise-new
(lambda (resolve reject)
(request url
- :parser (lambda () (libxml-parse-html-region (point-min) (point-max)))
+ :parser (lambda ()
+ (goto-char (point-min))
+ (while (re-search-forward ">\\*" nil t)
+ (replace-match ">-"))
+ (libxml-parse-html-region (point-min) (point-max)))
:error (cl-function (lambda (&rest args &key error-thrown &allow-other-keys)
(funcall reject error-thrown)))
:success (cl-function (lambda (&key data &allow-other-keys)
@@ -77,7 +81,8 @@ third one is 80.")
(insert "#+STARTUP: overview indent\n")
(cl-mapcar #'hnreader--print-frontpage-item things subtexts)
;; (setq-local org-confirm-elisp-link-function nil)
- (org-mode))))
+ (org-mode)
+ (goto-line 3))))
(defun hnreader--get-title (dom)
"Get title and link from DOM comment page."
@@ -91,7 +96,7 @@ third one is 80.")
(with-current-buffer (hnreader--get-hn-comment-buffer)
(read-only-mode -1)
(erase-buffer)
- (insert "#+STARTUP: overview indent\n")
+ (insert "#+STARTUP: indent\n")
(insert "#+TITLE: " (car title))
(insert "\n" (cdr title))
(dolist (comment comments)
@@ -102,7 +107,9 @@ third one is 80.")
(hnreader--get-comment-owner comment)))
(let ((shr-width 80))
(shr-insert-document (hnreader--get-comment comment))))
- (org-mode))))
+ (org-mode)
+ (org-shifttab 3)
+ (goto-line 3))))
(defun hnreader--get-img-tag-width (comment-dom)
"Get width attribute of img tag in COMMENT-DOM."