X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=ccba71639b54767e688450c2cf54754065f8f09b;hp=69639873e4ba6366724b60fb836c116d0f59d987;hb=bc4fbb5c3361454f9d18e03960c1febcbdcf0b9b;hpb=fff9ab154af67a4698b6daf77f05457131b22271 diff --git a/elpher.el b/elpher.el index 6963987..ccba716 100644 --- a/elpher.el +++ b/elpher.el @@ -1132,8 +1132,8 @@ If ADDRESS is not supplied or nil the record is rendered as an nil t)) (window (get-buffer-window elpher-buffer-name))) (when window - (setf (image-property image :max-width) (window-pixel-width window)) - (setf (image-property image :max-height) (window-pixel-height window))) + (setf (image-property image :max-width) (window-body-width window t)) + (setf (image-property image :max-height) (window-body-height window t))) (elpher-with-clean-buffer (insert-image image) (elpher-restore-pos))) @@ -1513,28 +1513,36 @@ by HEADER-LINE." "Insert a plain non-preformatted TEXT-LINE into a text/gemini document. This function uses Emacs' auto-fill to wrap text sensibly to a maximum width defined by `elpher-gemini-max-fill-width'." - (string-match "\\(^[ \t]*\\)\\(\\*[ \t]+\\|>[ \t]*\\)?" text-line) - (let* ((line-prefix (match-string 2 text-line)) - (processed-text-line - (if line-prefix - (cond ((string-prefix-p "*" line-prefix) - (concat - (replace-regexp-in-string "\\*" - elpher-gemini-bullet-string - (match-string 0 text-line)) - (substring text-line (match-end 0)))) - ((string-prefix-p ">" line-prefix) - (propertize text-line 'face 'elpher-gemini-quoted)) - (t text-line)) - text-line)) - (adaptive-fill-mode t) - ;; fill-prefix is important for adaptive-fill-mode: without - ;; it, multi-line list items are not indented correct - (fill-prefix (if (match-string 2 text-line) - (replace-regexp-in-string "[>\*]" " " (match-string 0 text-line)) - nil))) - (insert (elpher-process-text-for-display processed-text-line)) - (newline))) + (if (string-empty-p text-line) + (insert "\n") + (string-match + (rx (: line-start + (* (any " \t")) + (optional + (group (or (: "*" (+ (any " \t"))) + (: ">" (* (any " \t")))))))) + text-line) + (let* ((line-prefix (match-string 1 text-line)) + (processed-text-line + (if line-prefix + (cond ((string-prefix-p "*" line-prefix) + (concat + (replace-regexp-in-string "\\*" + elpher-gemini-bullet-string + (match-string 0 text-line)) + (substring text-line (match-end 0)))) + ((string-prefix-p ">" line-prefix) + (propertize text-line 'face 'elpher-gemini-quoted)) + (t text-line)) + text-line)) + (adaptive-fill-mode t) + ;; fill-prefix is important for adaptive-fill-mode: without + ;; it, multi-line list items are not indented correct + (fill-prefix (if (match-string 1 text-line) + (make-string (length (match-string 0 text-line)) ?\s) + nil))) + (insert (elpher-process-text-for-display processed-text-line)) + (newline)))) (defun elpher-render-gemini-map (data _parameters) "Render DATA as a gemini map file, PARAMETERS is currently unused."