changelog shortlog graph tags branches changeset files revisions annotate raw help

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
2 
3 ;; includes PLAIN-TEXT, BOLD, ITALIC, UNDERLINE, VERBATIM, CODE, and STRIKE-THROUGH.
4 
5 ;;; Code:
6 (in-package :organ)
7 
8 ;; Any string that doesn't match another object is considered a plain
9 ;; text object. Whitespace MAY be collapsed within any plain-text
10 ;; instance.
11 (defmacro extract-with-markup (char input)
12  `(with-lexer-environment (,input)
13  (when (char= ,char (consume))
14  (consume-until (make-matcher (is ,char))))))
15 
16 (define-org-object plain-text (contents))
17 
18 (define-org-parser (plain-text :from string)
19  (let ((res (org-create :plain-text)))
20  (setf (org-plain-text-contents res) input)
21  res))
22 
23 ;; *bold*
24 (define-org-object bold () :include plain-text)
25 
26 (define-org-parser (bold :from string)
27  (let ((res (org-create :bold)))
28  (setf (org-bold-contents res)
29  (extract-with-markup #\* input))
30  res))
31 
32 ;; /italic/
33 (define-org-object italic () :include plain-text)
34 
35 (define-org-parser (italic :from string)
36  (let ((res (org-create :italic)))
37  (setf (org-italic-contents res)
38  (extract-with-markup #\/ input))
39  res))
40 
41 ;; _underline_
42 (define-org-object underline () :include plain-text)
43 
44 (define-org-parser (underline :from string)
45  (let ((res (org-create :underline)))
46  (setf (org-underline-contents res)
47  (extract-with-markup #\_ input))
48  res))
49 
50 ;; =verbatim=
51 (define-org-object verbatim () :include plain-text)
52 
53 ;; FIXME 2023-12-27:
54 (define-org-parser (verbatim :from string)
55  (let ((res (org-create :verbatim)))
56  (setf (org-verbatim-contents res)
57  (extract-with-markup #\= input))
58  res))
59 
60 ;; ~code~
61 (define-org-object code () :include plain-text)
62 
63 (define-org-parser (code :from string)
64  (let ((res (org-create :code)))
65  (setf (org-code-contents res)
66  (extract-with-markup #\~ input))
67  res))
68 
69 ;; +strike-through+
70 (define-org-object strike-through () :include plain-text)
71 
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))
76  res))