Skip to content

Commit

Permalink
feat!: Update markup parser to require content
Browse files Browse the repository at this point in the history
Markup now requires something to be inside the markers in order to be treated as markup.
For example, this was treated as bold before:
```
**
```
But now it will be presented as plain text until something is added:
```
*foo*
```
  • Loading branch information
kristijanhusak committed Nov 6, 2023
1 parent 185f54e commit bbd2550
Showing 1 changed file with 51 additions and 52 deletions.
103 changes: 51 additions & 52 deletions queries/org/markup.scm
Original file line number Diff line number Diff line change
@@ -1,76 +1,75 @@
(paragraph ((expr "*" @bold.start) (expr "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end)))
(paragraph (expr "*" @bold.start "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end)))
(paragraph ((expr "~" @code.start) (expr "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end)))
(paragraph (expr "~" @code.start "~" @code.end (#org-is-valid-markup-range? @code.start @code.end)))
(paragraph ((expr "/" @italic.start) (expr "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end)))
(paragraph (expr "/" @italic.start "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end)))
(paragraph ((expr "_" @underline.start) (expr "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end)))
(paragraph (expr "_" @underline.start "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end)))
(paragraph ((expr "=" @verbatim.start) (expr "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(paragraph (expr "=" @verbatim.start "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(paragraph ((expr "+" @strikethrough.start) (expr "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(paragraph (expr "+" @strikethrough.start "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(paragraph ((expr "[" @hyperlink.start . "[") (expr "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end)))
(paragraph ((expr "*" @bold.start _) (expr _ "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end)))
(paragraph (expr "*" @bold.start _ "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end)))
(paragraph ((expr "~" @code.start _) (expr _ "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end)))
(paragraph (expr "~" @code.start _ "~" @code.end (#org-is-valid-markup-range? @code.start @code.end)))
(paragraph ((expr "/" @italic.start _) (expr _ "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end)))
(paragraph (expr "/" @italic.start _ "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end)))
(paragraph ((expr "_" @underline.start _) (expr _ "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end)))
(paragraph (expr "_" @underline.start _ "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end)))
(paragraph ((expr "=" @verbatim.start _) (expr _ "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(paragraph (expr "=" @verbatim.start _ "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(paragraph ((expr "+" @strikethrough.start _) (expr _ "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(paragraph (expr "+" @strikethrough.start _ "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(paragraph ((expr "[" @hyperlink.start . "[" _) (expr _ "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end)))
(paragraph (expr "[" @hyperlink.start . "[" _ "]" . "]" @hyperlink.end (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end)))
(paragraph ((expr ("\\" @text.math.start.left "(" @text.math.start.right)) (expr ("\\" ")" @text.math.end)) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(paragraph (expr "\\" @text.math.start.left "(" @text.math.start.right "\\" ")" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(paragraph ((expr ("\\" @text.math.start.left ("str")+ @text.math.start.right "{")) (expr "}" @text.math.end) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(paragraph (expr "\\" @text.math.start.left ("str")+ @text.math.start.right "{" "}" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(paragraph (expr "\\" @text.math.start.left ("str")+ @text.math.start.right @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))

(item ((expr "*" @bold.start) (expr "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end)))
(item (expr "*" @bold.start "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end)))
(item ((expr "~" @code.start) (expr "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end)))
(item (expr "~" @code.start "~" @code.end (#org-is-valid-markup-range? @code.start @code.end)))
(item ((expr "/" @italic.start) (expr "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end)))
(item (expr "/" @italic.start "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end)))
(item ((expr "_" @underline.start) (expr "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end)))
(item (expr "_" @underline.start "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end)))
(item ((expr "=" @verbatim.start) (expr "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(item (expr "=" @verbatim.start "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(item ((expr "+" @strikethrough.start) (expr "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(item (expr "+" @strikethrough.start "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(item ((expr "[" @hyperlink.start . "[") (expr "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end)))
(item ((expr "*" @bold.start _) (expr _ "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end)))
(item (expr "*" @bold.start _ "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end)))
(item ((expr "~" @code.start _) (expr _ "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end)))
(item (expr "~" @code.start _ "~" @code.end (#org-is-valid-markup-range? @code.start @code.end)))
(item ((expr "/" @italic.start _) (expr _ "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end)))
(item (expr "/" @italic.start _ "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end)))
(item ((expr "_" @underline.start _) (expr _ "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end)))
(item (expr "_" @underline.start _ "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end)))
(item ((expr "=" @verbatim.start _) (expr _ "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(item (expr "=" @verbatim.start _ "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end)))
(item ((expr "+" @strikethrough.start _) (expr _ "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(item (expr "+" @strikethrough.start _ "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end)))
(item ((expr "[" @hyperlink.start . "[" _) (expr _ "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end)))
(item (expr "[" @hyperlink.start . "[" _ "]" . "]" @hyperlink.end (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end)))
(item ((expr ("\\" @text.math.start.left "(" @text.math.start.right)) (expr ("\\" ")" @text.math.end)) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(item (expr "\\" @text.math.start.left "(" @text.math.start.right "\\" ")" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(item ((expr ("\\" @text.math.start.left ("str")+ @text.math.start.right "{")) (expr "}" @text.math.end) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(item (expr "\\" @text.math.start.left ("str")+ @text.math.start.right "{" "}" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))
(item (expr "\\" @text.math.start.left ("str")+ @text.math.start.right @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end)))

(cell (contents ((expr "*" @bold.start) (expr "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end))))
(cell (contents (expr "*" @bold.start "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end))))
(cell (contents ((expr "~" @code.start) (expr "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end))))
(cell (contents (expr "~" @code.start "~" @code.end (#org-is-valid-markup-range? @code.start @code.end))))
(cell (contents ((expr "/" @italic.start) (expr "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end))))
(cell (contents (expr "/" @italic.start "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end))))
(cell (contents ((expr "_" @underline.start) (expr "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end))))
(cell (contents (expr "_" @underline.start "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end))))
(cell (contents ((expr "=" @verbatim.start) (expr "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(cell (contents (expr "=" @verbatim.start "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(cell (contents ((expr "+" @strikethrough.start) (expr "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(cell (contents (expr "+" @strikethrough.start "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(cell (contents ((expr "[" @hyperlink.start . "[") (expr "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end))))
(cell (contents ((expr "*" @bold.start _) (expr _ "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end))))
(cell (contents (expr "*" @bold.start _ "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end))))
(cell (contents ((expr "~" @code.start _) (expr _ "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end))))
(cell (contents (expr "~" @code.start _ "~" @code.end (#org-is-valid-markup-range? @code.start @code.end))))
(cell (contents (expr "/" @italic.start _ "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end))))
(cell (contents ((expr "_" @underline.start _) (expr _ "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end))))
(cell (contents (expr "_" @underline.start _ "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end))))
(cell (contents ((expr "=" @verbatim.start _) (expr _ "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(cell (contents (expr "=" @verbatim.start _ "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(cell (contents ((expr "+" @strikethrough.start _) (expr _ "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(cell (contents (expr "+" @strikethrough.start _ "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(cell (contents ((expr "[" @hyperlink.start . "[" _) (expr _ "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end))))
(cell (contents (expr "[" @hyperlink.start . "[" _ "]" . "]" @hyperlink.end (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end))))
(cell (contents ((expr ("\\" @text.math.start.left "(" @text.math.start.right)) (expr ("\\" ")" @text.math.end)) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))
(cell (contents (expr "\\" @text.math.start.left "(" @text.math.start.right "\\" ")" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))
(cell (contents ((expr ("\\" @text.math.start.left ("str")+ @text.math.start.right "{")) (expr "}" @text.math.end) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))
(cell (contents (expr "\\" @text.math.start.left ("str")+ @text.math.start.right "{" "}" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))
(cell (contents (expr "\\" @text.math.start.left ("str")+ @text.math.start.right @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))

(drawer (contents ((expr "*" @bold.start) (expr "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end))))
(drawer (contents (expr "*" @bold.start "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end))))
(drawer (contents ((expr "~" @code.start) (expr "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end))))
(drawer (contents (expr "~" @code.start "~" @code.end (#org-is-valid-markup-range? @code.start @code.end))))
(drawer (contents ((expr "/" @italic.start) (expr "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end))))
(drawer (contents (expr "/" @italic.start "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end))))
(drawer (contents ((expr "_" @underline.start) (expr "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end))))
(drawer (contents (expr "_" @underline.start "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end))))
(drawer (contents ((expr "=" @verbatim.start) (expr "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(drawer (contents (expr "=" @verbatim.start "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(drawer (contents ((expr "+" @strikethrough.start) (expr "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(drawer (contents (expr "+" @strikethrough.start "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(drawer (contents ((expr "[" @hyperlink.start . "[") (expr "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end))))
(drawer (contents ((expr "*" @bold.start _) (expr _ "*" @bold.end) (#org-is-valid-markup-range? @bold.start @bold.end))))
(drawer (contents (expr "*" @bold.start _ "*" @bold.end (#org-is-valid-markup-range? @bold.start @bold.end))))
(drawer (contents ((expr "~" @code.start _) (expr _ "~" @code.end) (#org-is-valid-markup-range? @code.start @code.end))))
(drawer (contents (expr "~" @code.start _ "~" @code.end (#org-is-valid-markup-range? @code.start @code.end))))
(drawer (contents ((expr "/" @italic.start _) (expr _ "/" @italic.end) (#org-is-valid-markup-range? @italic.start @italic.end))))
(drawer (contents (expr "/" @italic.start _ "/" @italic.end (#org-is-valid-markup-range? @italic.start @italic.end))))
(drawer (contents ((expr "_" @underline.start _) (expr _ "_" @underline.end) (#org-is-valid-markup-range? @underline.start @underline.end))))
(drawer (contents (expr "_" @underline.start _ "_" @underline.end (#org-is-valid-markup-range? @underline.start @underline.end))))
(drawer (contents ((expr "=" @verbatim.start _) (expr _ "=" @verbatim.end) (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(drawer (contents (expr "=" @verbatim.start _ "=" @verbatim.end (#org-is-valid-markup-range? @verbatim.start @verbatim.end))))
(drawer (contents ((expr "+" @strikethrough.start _) (expr _ "+" @strikethrough.end) (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(drawer (contents (expr "+" @strikethrough.start _ "+" @strikethrough.end (#org-is-valid-markup-range? @strikethrough.start @strikethrough.end))))
(drawer (contents ((expr "[" @hyperlink.start . "[" _) (expr _ "]" . "]" @hyperlink.end) (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end))))
(drawer (contents (expr "[" @hyperlink.start . "[" _ "]" . "]" @hyperlink.end (#org-is-valid-hyperlink-range? @hyperlink.start @hyperlink.end))))
(drawer (contents ((expr ("\\" @text.math.start.left "(" @text.math.start.right)) (expr ("\\" ")" @text.math.end)) (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))
(drawer (contents (expr "\\" @text.math.start.left "(" @text.math.start.right "\\" ")" @text.math.end (#org-is-valid-latex-range? @text.math.start.left @text.math.start.right @text.math.end))))
Expand Down

0 comments on commit bbd2550

Please sign in to comment.