From 5201953a08573ec792035a9c312f01dd47a3c6c6 Mon Sep 17 00:00:00 2001 From: cage Date: Sun, 9 May 2021 17:01:51 +0200 Subject: [PATCH] - [gemini] fixed parsing of quoted lines, an empty line can be part of the quote. --- etc/shared.conf | 2 +- src/gemini/gemini-parser.lisp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/etc/shared.conf b/etc/shared.conf index 78f28e0..47d2753 100644 --- a/etc/shared.conf +++ b/etc/shared.conf @@ -119,7 +119,7 @@ color-regexp = "➶ .+" magenta bold # header level 1 -color-regexp = "🞂 .+" white bold +color-regexp = "^🞂.*" white bold # header level 2 diff --git a/src/gemini/gemini-parser.lisp b/src/gemini/gemini-parser.lisp index cf8b147..08f64cc 100644 --- a/src/gemini/gemini-parser.lisp +++ b/src/gemini/gemini-parser.lisp @@ -165,10 +165,12 @@ (list (coerce (second a) 'string)))))) (defrule quote-line (and quote-prefix - text-line) + (? text-line)) (:function (lambda (a) (list (first a) nil - (tag-value (second a)))))) + (if (second a) + (tag-value (second a)) + ""))))) (defrule gemini-file (* (or h3 h2 @@ -467,11 +469,15 @@ (format nil "~a~a~%" (link-prefix-gemini theme) link-name) (format nil "~a~a~%" (link-prefix-other theme) link-name))) (fit-quote-lines (line win-width) - (let* ((justified (flush-left-mono-text (split-words line) + (let* ((words (split-words line)) + (quote-prefix (quote-prefix theme)) + (justified (flush-left-mono-text words (- win-width - (length (quote-prefix theme))))) - (lines (mapcar (lambda (a) (strcat (quote-prefix theme) a)) - justified))) + (length quote-prefix)))) + (lines (if justified + (mapcar (lambda (a) (strcat quote-prefix a)) + justified) + quote-prefix))) (make-quoted-lines (join-with-strings lines (format nil "~%"))))) (pre-alt-text (node) (trim (html-utils:attribute-value (html-utils:find-attribute :alt node))))