Mercurial > core / lisp/lib/organ/object/markup.lisp
changeset 698: |
96958d3eb5b0 |
parent: |
d20482540d67
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
1 ;;; lib/organ/object/markup.lisp --- Org Markup 3 ;; includes PLAIN-TEXT, BOLD, ITALIC, UNDERLINE, VERBATIM, CODE, and STRIKE-THROUGH. 8 ;; Any string that doesn't match another object is considered a plain 9 ;; text object. Whitespace MAY be collapsed within any plain-text 11 (defmacro extract-with-markup (char input) 12 `(with-lexer-environment (,input) 13 (when (char= ,char (consume)) 14 (consume-until (make-matcher (is ,char)))))) 16 (define-org-object plain-text (contents)) 18 (define-org-parser (plain-text :from string) 19 (let ((res (org-create :plain-text))) 20 (setf (org-plain-text-contents res) input) 24 (define-org-object bold () :include plain-text) 26 (define-org-parser (bold :from string) 27 (let ((res (org-create :bold))) 28 (setf (org-bold-contents res) 29 (extract-with-markup #\* input)) 33 (define-org-object italic () :include plain-text) 35 (define-org-parser (italic :from string) 36 (let ((res (org-create :italic))) 37 (setf (org-italic-contents res) 38 (extract-with-markup #\/ input)) 42 (define-org-object underline () :include plain-text) 44 (define-org-parser (underline :from string) 45 (let ((res (org-create :underline))) 46 (setf (org-underline-contents res) 47 (extract-with-markup #\_ input)) 51 (define-org-object verbatim () :include plain-text) 54 (define-org-parser (verbatim :from string) 55 (let ((res (org-create :verbatim))) 56 (setf (org-verbatim-contents res) 57 (extract-with-markup #\= input)) 61 (define-org-object code () :include plain-text) 63 (define-org-parser (code :from string) 64 (let ((res (org-create :code))) 65 (setf (org-code-contents res) 66 (extract-with-markup #\~ input)) 70 (define-org-object strike-through () :include plain-text) 72 (define-org-parser (strike-through :from string) 73 (let ((res (org-create :strike-through))) 74 (setf (org-strike-through-contents res) 75 (extract-with-markup #\+ input))