From 71a93991a03f0e9ea9b381d1a9d1acb994fc4a4d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 29 Sep 2022 11:53:30 +1000 Subject: linking in documentation Only to module source for now. --- hcel-utils.el | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'hcel-utils.el') diff --git a/hcel-utils.el b/hcel-utils.el index 18a8c07..a35a441 100644 --- a/hcel-utils.el +++ b/hcel-utils.el @@ -147,11 +147,37 @@ Example of an idSrcSpan: (defun hcel-render-html (html) (when html + ;; (hcel-debug-html html) (with-temp-buffer (insert html) - (shr-render-region (point-min) (point-max)) + (let ((shr-external-rendering-functions + '((span . hcel-tag-span)))) + (shr-render-region (point-min) (point-max))) (buffer-string)))) +(defun hcel-debug-html (html) + (with-temp-buffer + (insert html) + (pp (libxml-parse-html-region (point-min) (point-max))))) + +(defun hcel-tag-span (dom) + (let ((start (point))) + (shr-tag-span dom) + (mapc (lambda (attr) + (cond ((eq (car attr) 'data-location) + (put-text-property start (point) + 'location-info + (json-read-from-string (cdr attr))) + (make-text-button start (point) + 'action + (lambda (m) + (hcel-load-module-location-info + (hcel-to-exact-location + (get-text-property m 'location-info)))) + 'face 'button) +))) + (dom-attributes dom)))) + (defun hcel-text-property-near-point (prop) "Find property prop at point, or just before point." (or (get-text-property (point) prop) -- cgit v1.2.3