fix <small> rendering </small> and make it multi-line

This commit is contained in:
Miranda Marquez 2024-09-14 16:54:36 -08:00
parent 0102015cd3
commit 5eaabd1734

View File

@ -69,8 +69,9 @@ returns nil if such an emoji does not exist."
(overlay-put ov 'modification-hooks (overlay-put ov 'modification-hooks
(list 'org-display-inline-remove-overlay)))))) (list 'org-display-inline-remove-overlay))))))
(defvar sharkey/small-rx (defvar sharkey/small-rx
;; this might display a bit weird... sorgy
(rx (group-n 1 "<small>") (rx (group-n 1 "<small>")
(group-n 2 (+ any)) (group-n 2 (+? (or "\n" any)))
(group-n 3 "</small>"))) (group-n 3 "</small>")))
(defun next-small-overlay (&optional limit) (defun next-small-overlay (&optional limit)
"logic from `next-emoji-overlay' but for mfm <small></small> tag." "logic from `next-emoji-overlay' but for mfm <small></small> tag."
@ -87,30 +88,56 @@ returns nil if such an emoji does not exist."
(text (buffer-substring text-beg text-end)) (text (buffer-substring text-beg text-end))
(text-ov (make-overlay text-beg text-end)) (text-ov (make-overlay text-beg text-end))
) )
;; (overlay-put openr-ov 'display "") (overlay-put openr-ov 'display "")
;; (overlay-put close-ov 'display "") (overlay-put close-ov 'display "")
(put-text-property openr-beg openr-end 'invisible t) ;; (put-text-property openr-beg openr-end 'invisible t)
(put-text-property close-beg close-end 'invisible t) ;; (put-text-property close-beg close-end 'invisible t)
(overlay-put text-ov 'help-echo text) ;; (overlay-put text-ov 'help-echo text)
(overlay-put text-ov 'display '(height 0.8)) ;; (put-text-property text-beg text-end 'display '(height 0.8))
(overlay-put placehoverlay 'display '(height 0.8))
(overlay-put placehoverlay 'modification-hooks (overlay-put placehoverlay 'modification-hooks
(list
'mir/remove-all-overlays
'org-display-inline-remove-overlay))
(overlay-put openr-ov 'modification-hooks
(list 'org-display-inline-remove-overlay))
(overlay-put close-ov 'modification-hooks
(list 'org-display-inline-remove-overlay)) (list 'org-display-inline-remove-overlay))
;; (overlay-put openr-ov 'org-image-overlay t) ;; (overlay-put openr-ov 'org-image-overlay t)
;; (overlay-put close-ov 'org-image-overlay t) ;; (overlay-put close-ov 'org-image-overlay t)
;; (overlay-put text-ov 'org-image-overlay t) ;; (overlay-put text-ov 'org-image-overlay t)
))) )))
(defun mir/remove-all-overlays (&optional overlay nyl beg end)
"Delete all overlays resting on current line."
;; (message "%s" throwaway)
;; ^^^--> list of overlay, nil, bounds
(let* ((start-bound (or beg (pos-bol)))
(end-bound (or end (pos-eol))))
(--map
(mapcar #'delete-overlay (overlays-at it))
(number-sequence start-bound end-bound)))
nil)
(defun mir/overlay-bounds (overlay)
"Return a cons of `(start . end)' for OVERLAY."
(cons
(overlay-start overlay)
(overlay-end overlay)))
(defface mfm-delimiter-invis-face (defface mfm-delimiter-invis-face
'((t (:string ""))) '((t (:string "")))
"Face for misskey markdown elements such as <small> type stuff.") "Face for misskey markdown elements such as <small> type stuff.")
;; <small>this :neofox is smol</small> ;; the fact is, <small>this :neofox: is smol</small
;; <small>this :neocat: is also smol</small> apparently
;; <small>
;; this comment is entirely small
; </small>
(font-lock-add-keywords (font-lock-add-keywords
nil ; this must needs be nil nil ; this must needs be nil
`((next-emoji-overlay (0 'font-lock-keyword-face t)) `((next-emoji-overlay (0 'font-lock-keyword-face t))
;; (next-small-overlay (0 'font-lock-keyword-face t)) (next-small-overlay (0 'font-lock-keyword-face t))
(,sharkey/small-rx 1 'mfm-delimiter-invis-face t) ;; (,sharkey/small-rx 1 'mfm-delimiter-invis-face t)
(,sharkey/small-rx 3 'mfm-delimiter-invis-face t) ;; (,sharkey/small-rx 3 'mfm-delimiter-invis-face t)
) t) ) t)
(define-minor-mode fedimoji-mode (define-minor-mode fedimoji-mode