branch: externals/hyperbole commit c593db32e41b41b975ef315bf2978a78695f511d Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Fixes for kexport:display and klink.el --- ChangeLog | 8 ++++++++ kotl/kexport.el | 33 ++++++++++++++++----------------- kotl/klink.el | 35 +++++++++++++++++++++++++---------- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b607b3..83a1873 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2021-05-22 Bob Weiner <r...@gnu.org> +* kotl/kexport.el (kexport:html-file-klink): Change '\0' back to + '\\&' to prevent klink nul char insertion bug. + (kexport:html): Fix cell label vertical alignment + with table row-level valign=text-bottom. + +* kotl/klink.el (klink:ignore-modes, klink:c-style-modes): Add so + can customize. + * hsettings.el (hyperbole-web-search-alist): Update 'gitHub' name. diff --git a/kotl/kexport.el b/kotl/kexport.el index cbbd1e0..a9773ee 100644 --- a/kotl/kexport.el +++ b/kotl/kexport.el @@ -263,17 +263,16 @@ STILL TODO: (kotl-mode:beginning-of-buffer) (setq kexport:input-filename buffer-file-name) - ;; Use the first line of the first cell as the default HTML document title. - (setq title (save-excursion - (kotl-mode:beginning-of-buffer) - (kcell-view:contents))) - (if (string-match "\n" title) - (setq title (substring title 0 (match-beginning 0)))) - ;; If called interactively, prompt user for the title to use. (if (called-interactively-p 'interactive) (setq title (read-string (format "Title for %s: " output-to-buf-name) - title))) + title)) + ;; Otherwise, use the first line of the first cell as the default HTML document title. + (setq title (save-excursion + (kotl-mode:beginning-of-buffer) + (kcell-view:contents))) + (when (string-match "\n" title) + (setq title (substring title 0 (match-beginning 0))))) (princ "<html><head>\n\n") (princ "<a id=\"top\"></a><a id=\"k0\"></a>\n") @@ -310,8 +309,8 @@ STILL TODO: (while (> i 1) (princ "<ul>") (setq i (1- i))) - (princ "<li list-style-type=none><table><tr>\n") - (princ "<td width=1% valign=top>") + (princ "<li list-style-type=none>\n<table><tr valign=text-bottom>\n") + (princ "<td width=1%>") (princ (format "<span class=\"fas fa-chevron-down fa-fw\"%s></span>" (if is-parent "" @@ -319,10 +318,10 @@ STILL TODO: ;; show collapsible chevron when not a parent " style=\"visibility:hidden\""))) (princ "</td>\n") - (princ "<td width=2% valign=top>\n") + (princ "<td width=2%>") (setq label (kcell-view:label)) (princ (format "<a id=\"k%s\"></a>" label)) - (princ (format "<a id=\"k%s\"></a>\n" (kcell-view:idstamp))) + (princ (format "<a id=\"k%s\"></a>" (kcell-view:idstamp))) (princ (format "<pre><font %s>%s%s</font></pre>\n" kexport:label-html-font-attributes @@ -369,12 +368,12 @@ Works exclusively within a call to `hypb:replace-match-string'." (match-end 1)))) (if (equal filename (file-name-nondirectory kexport:input-filename)) - "<a href=\"#k\\2\">\0</a>" - (format "<a href=\"file://%s#k\\2\">\0</a>" + "<a href=\"#k\\2\">\\&</a>" + (format "<a href=\"file://%s#k\\2\">\\&</a>" (expand-file-name filename - (if kexport:input-filename - (file-name-directory - kexport:input-filename))))))) + (when kexport:input-filename + (file-name-directory + kexport:input-filename))))))) (defun kexport:html-markup (string) "Perform replacements on STRING specified by `kexport:html-replacement-alist'." diff --git a/kotl/klink.el b/kotl/klink.el index 6338828..209cc57 100644 --- a/kotl/klink.el +++ b/kotl/klink.el @@ -64,6 +64,22 @@ (eval-when-compile (require 'hbut)) ;; For defib. ;;; ************************************************************************ +;;; Public variables +;;; ************************************************************************ + +(defcustom klink:ignore-modes + '(occur-mode moccur-mode amoccur-mode shell-mode telnet-mode ssh-mode term-mode) + "Major modes in which to ignore potential klinks to avoid false positives." + :type '(list function) + :group 'hyperbole-koutliner) + +(defcustom klink:c-style-modes + '(c-mode c++-mode objc-mode java-mode) + "Major modes in which to ignore potential klinks to avoid false positives." + :type '(list function) + :group 'hyperbole-koutliner) + +;;; ************************************************************************ ;;; Public functions ;;; ************************************************************************ @@ -115,22 +131,21 @@ link-end-position, (including delimiters)." (let (bol klink referent path) (if (and ;; Avoid false matches in certain modes. - (not (memq major-mode '(occur-mode moccur-mode amoccur-mode - shell-mode telnet-mode ssh-mode term-mode))) + (not (memq major-mode klink:ignore-modes)) ;; If this is an OO-Browser listing buffer, ignore anything that ;; looks like a klink, e.g. a C++ <template> class. (if (fboundp 'br-browser-buffer-p) (not (br-browser-buffer-p)) t) ;; If in a C-based mode, Klinks can only occur within comments. - (if (and (memq major-mode '(c-mode c++-mode objc-mode java-mode)) + (if (and (memq major-mode klink:c-style-modes) (fboundp 'c-within-comment-p)) (or (c-within-comment-p) (save-excursion (and (re-search-backward "//\\|\n" nil t) (looking-at "//")))) t) - ;; Don't match to C/Objective-C/C++ lines like: #include < path > - (if (memq major-mode '(c-mode c++-mode objc-mode)) + ;; Don't match to C-style lines like: #include < path > + (if (memq major-mode klink:c-style-modes) (save-excursion (beginning-of-line) (setq bol (point)) @@ -168,7 +183,7 @@ link-end-position, (including delimiters)." ;;; ************************************************************************ (defib klink () - "Follows a link delimited by <> to a koutline cell. + "Follow a link delimited by <> to a koutline cell. See documentation for the `link-to-kotl' function for valid klink formats." (let* ((link-and-pos (klink:at-p)) (link (car link-and-pos)) @@ -178,7 +193,7 @@ See documentation for the `link-to-kotl' function for valid klink formats." (hact 'klink:act link start-pos))))) (defact link-to-kotl (link) - "Displays at the top of another window the referent pointed to by LINK. + "Display at the top of another window the referent pointed to by LINK. LINK may be of any of the following forms, with or without delimiters: < pathname [, cell-ref] > < [-!&] pathname > @@ -204,8 +219,8 @@ See documentation for `kcell:ref-to-id' for valid cell-ref formats." link) ;; < pathname [, cell-ref] > (hact 'link-to-kcell (match-string 1 link) - (if (match-end 3) - (kcell:ref-to-id (match-string 3 link))))) + (when (match-end 3) + (kcell:ref-to-id (match-string 3 link))))) ((string-match "\\`<?\\s-*\\(\\([-!&]\\)?\\s-*[^ \t\n\r\f,<>]+\\)\\s-*>?\\'" link) ;; < [-!&] pathname > @@ -283,7 +298,7 @@ Assume point is in klink referent buffer, where the klink points." (klink:replace-label klink link-buf start new-label))))) ;;; ************************************************************************ -;;; Private variables. +;;; Private variables ;;; ************************************************************************ (defvar klink:cell-ref-regexp