emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/kiwix 801c924 2/7: Make elquery optional by use Emacs b


From: Stefan Monnier
Subject: [elpa] externals/kiwix 801c924 2/7: Make elquery optional by use Emacs built-in library libxml and dom
Date: Wed, 11 Aug 2021 15:58:43 -0400 (EDT)

branch: externals/kiwix
commit 801c9246a029d6fb0673fc4eea6cb61bd2651849
Author: stardiviner <numbchild@gmail.com>
Commit: stardiviner <numbchild@gmail.com>

    Make elquery optional by use Emacs built-in library libxml and dom
---
 kiwix.el | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/kiwix.el b/kiwix.el
index d715180..0572e56 100644
--- a/kiwix.el
+++ b/kiwix.el
@@ -61,6 +61,7 @@
 (require 'subr-x)
 (require 'thingatpt)
 (require 'json)
+(require 'dom)
 
 (declare-function helm "helm")
 (declare-function helm-build-async-source "helm")
@@ -155,8 +156,23 @@ Set it to ‘t’ will use Emacs built-in ‘completing-read’."
         :type "GET"
         :sync t
         :parser (lambda ()
-                  (if (not (featurep 'elquery))
-                      (print "PLACEHOLDER: use libxml by default")
+                  (if (libxml-available-p) ; (and (not (featurep 'elquery)) 
(libxml-available-p))
+                      (let ((document (libxml-parse-html-region (point-min) 
(point-max))))
+                        (setq kiwix-libraries
+                              (mapcar
+                               ;; remove "/" from "/<zim_library_name>"
+                               (lambda (slash_library)
+                                 (substring slash_library 1 nil))
+                               ;; list of "/<zim_library_name>"
+                               (mapcar
+                                (lambda (a)
+                                  (dom-attr a 'href))
+                                (dom-by-tag
+                                 (dom-by-class
+                                  (dom-by-class document "kiwix") ; <div 
class="kiwix">
+                                  "book__list")                   ; <div 
class="book__list">
+                                 'a) ; <a 
href="/wikipedia_zh_all_maxi_2021-03">
+                                ))))
                     (require 'elquery)
                     (let ((html (elquery-read-string
                                  (buffer-substring-no-properties (point-min) 
(point-max)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]