1
0
Fork 0

- changed 'raw-text' to 'source-line';

- added ocstring to 'search-gemini-fragment'.
This commit is contained in:
cage 2021-11-06 11:26:20 +01:00
parent 768e4a220b
commit 5bbd5100c8
3 changed files with 21 additions and 19 deletions

View File

@ -395,11 +395,11 @@
:initform nil :initform nil
:accessor viewport))) :accessor viewport)))
(defclass with-raw-text () (defclass with-source-line ()
((raw-text ((source-line
:initform nil :initform nil
:initarg :raw-text :initarg :source-line
:accessor raw-text) :accessor source-line)
(source-line-id (source-line-id
:initform nil :initform nil
:initarg :source-line-id :initarg :source-line-id
@ -410,8 +410,8 @@
:reader artificialp :reader artificialp
:writer (setf artificial)))) :writer (setf artificial))))
(defmethod print-object ((object with-raw-text) stream) (defmethod print-object ((object with-source-line) stream)
(format stream "sid: ~a raw-text: ~a" (source-line-id object) (raw-text object))) (format stream "sid: ~a source-line: ~a" (source-line-id object) (source-line object)))
(defclass with-group-id () (defclass with-group-id ()
((group-id ((group-id
@ -437,7 +437,7 @@
:initarg :pre-group-id :initarg :pre-group-id
:accessor pre-group-id))) :accessor pre-group-id)))
(defclass pre-start (with-group-id with-pre-group-id with-alt-text with-raw-text) ()) (defclass pre-start (with-group-id with-pre-group-id with-alt-text with-source-line) ())
(defmethod print-object ((object pre-start) stream) (defmethod print-object ((object pre-start) stream)
(print-unreadable-object (object stream :type t :identity t) (print-unreadable-object (object stream :type t :identity t)
@ -449,12 +449,12 @@
:group-id group-id :group-id group-id
:pre-group-id pre-group-id)) :pre-group-id pre-group-id))
(defclass pre-end (with-raw-text) ()) (defclass pre-end (with-source-line) ())
(defun make-pre-end () (defun make-pre-end ()
(make-instance 'pre-end)) (make-instance 'pre-end))
(defclass quoted-lines (with-group-id with-lines with-raw-text) (defclass quoted-lines (with-group-id with-lines with-source-line)
((prefix ((prefix
:initform "@ " :initform "@ "
:initarg :prefix :initarg :prefix
@ -466,7 +466,7 @@
:group-id group-id :group-id group-id
:lines (list text))) :lines (list text)))
(defclass pre-line (with-group-id with-pre-group-id with-lines with-alt-text with-raw-text) ()) (defclass pre-line (with-group-id with-pre-group-id with-lines with-alt-text with-source-line) ())
(defmethod print-object ((object pre-line) stream) (defmethod print-object ((object pre-line) stream)
(print-unreadable-object (object stream :type t) (print-unreadable-object (object stream :type t)
@ -483,13 +483,13 @@
:pre-group-id pre-group-id :pre-group-id pre-group-id
:alt-text alt-text)) :alt-text alt-text))
(defclass vertical-space (with-group-id with-raw-text) (defclass vertical-space (with-group-id with-source-line)
((size ((size
:initform 1 :initform 1
:initarg :size :initarg :size
:accessor size))) :accessor size)))
(defclass header-line (with-group-id with-lines with-raw-text) (defclass header-line (with-group-id with-lines with-source-line)
((level ((level
:initform nil :initform nil
:initarg :level :initarg :level
@ -502,14 +502,14 @@
:level level :level level
:artificial artificial)) :artificial artificial))
(defclass unordered-list-line (with-group-id with-lines with-raw-text) ()) (defclass unordered-list-line (with-group-id with-lines with-source-line) ())
(defun make-unordered-list-line (text header-group-id) (defun make-unordered-list-line (text header-group-id)
(make-instance 'unordered-list-line (make-instance 'unordered-list-line
:group-id header-group-id :group-id header-group-id
:lines (list text))) :lines (list text)))
(defclass link-line (with-group-id with-raw-text) (defclass link-line (with-group-id with-source-line)
((link-text ((link-text
:initarg :link-text :initarg :link-text
:initform nil :initform nil
@ -530,7 +530,7 @@
:link-name link-name :link-name link-name
:link-value link-value)) :link-value link-value))
(defclass simple-line (with-group-id with-raw-text) (defclass simple-line (with-group-id with-source-line)
((text-line ((text-line
:initarg :text-line :initarg :text-line
:initform nil :initform nil
@ -594,12 +594,12 @@
((typep thing 'list) ((typep thing 'list)
(mapcar (lambda (a) (mapcar (lambda (a)
(setf (source-line-id a) source-line-id) (setf (source-line-id a) source-line-id)
(setf (raw-text a) source-line) (setf (source-line a) source-line)
a) a)
thing)) thing))
(t (t
(setf (source-line-id thing) source-line-id) (setf (source-line-id thing) source-line-id)
(setf (raw-text thing) source-line) (setf (source-line thing) source-line)
thing))) thing)))
(build-row (node) (build-row (node)
(let ((source-line (extract-source-line node)) (let ((source-line (extract-source-line node))

View File

@ -71,7 +71,7 @@
:h3-prefix :h3-prefix
:quote-prefix :quote-prefix
:bullet-prefix :bullet-prefix
:raw-text :source-line
:source-line-id :source-line-id
:artificialp :artificialp
:artificial :artificial

View File

@ -694,12 +694,14 @@
(defun original-source-metadata (row) (defun original-source-metadata (row)
(let* ((original-line (row-get-original-object row)) (let* ((original-line (row-get-original-object row))
(source-line (gemini-parser:raw-text original-line)) (source-line (gemini-parser:source-line original-line))
(source-line-id (gemini-parser:source-line-id original-line)) (source-line-id (gemini-parser:source-line-id original-line))
(artificialp (gemini-parser:artificialp original-line))) (artificialp (gemini-parser:artificialp original-line)))
(values source-line-id source-line artificialp))) (values source-line-id source-line artificialp)))
(defun search-gemini-fragment (window fragment) (defun search-gemini-fragment (window fragment)
"Search `fragment' in the source lines of the gemini steams and -if
fragment matches- move the window to the line when matching occurred."
(labels ((prefix-diff (text-rows source-line) (labels ((prefix-diff (text-rows source-line)
(- (length (first (split-words (first text-rows)))) (- (length (first (split-words (first text-rows))))
(length (first (split-words source-line))))) (length (first (split-words source-line)))))