diff options
author | Yuchen Pei <hi@ypei.me> | 2022-09-29 11:53:30 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-09-29 11:53:30 +1000 |
commit | 71a93991a03f0e9ea9b381d1a9d1acb994fc4a4d (patch) | |
tree | a0b80a18cc84eb41a0ceda0ec552d9bdc95a5814 /hcel-utils.el | |
parent | 19b43ada7e304221680df6e6fb53383d9a367d7c (diff) |
linking in documentation
Only to module source for now.
Diffstat (limited to 'hcel-utils.el')
-rw-r--r-- | hcel-utils.el | 28 |
1 files changed, 27 insertions, 1 deletions
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) |