Skip to content

Commit fab7af3

Browse files
committed
chore!: Version 1.0.0
1 parent e2a7a19 commit fab7af3

File tree

4 files changed

+78
-48
lines changed

4 files changed

+78
-48
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "tree-sitter-org"
33
description = "org grammar for the tree-sitter parsing library"
4-
version = "0.0.1"
4+
version = "1.0.0"
55
keywords = ["incremental", "parsing", "org"]
66
categories = ["parsing", "text-editors"]
77
repository = "https://github.com/milisims/tree-sitter-org"
8-
edition = "2021"
8+
edition = "2022"
99
license = "MIT"
1010

1111
build = "bindings/rust/build.rs"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Emilia Simmons
3+
Copyright (c) 2021-2022 Emilia Simmons
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 74 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# tree-sitter-org
22

3-
**Unstable**: This build will change.
4-
5-
Org grammar for tree-sitter. It is not meant to implement emacs' orgmode
6-
parser, but to implement a grammar that can usefully parse org files to be used
7-
in neovim and any library that uses tree-sitter parsers.
3+
Org grammar for tree-sitter. Here, the goal is to implement a grammar that can
4+
usefully parse org files to be used in any library that uses tree-sitter
5+
parsers. It is not meant to implement emacs' orgmode parser exactly, which is
6+
inherently more dynamic than tree-sitter easily allows.
87

98
## Overview
109

@@ -14,11 +13,11 @@ Refer to the tests in `corpus` for examples.
1413
- Top level node: `(document)`
1514
- Document contains: `(directive)* (body)? (section)*`
1615
- Section contains: `(headline) (plan)? (property_drawer)? (body)?`
17-
- headline contains: (stars, title, tag?+)
16+
- headline contains: `((stars), (item)?, (tag_list)?)`
1817
- body contains: `(element)+`
19-
- element contains: `(directive)* choose(paragraph, drawer, comment, footnote def, list, block, dynamic block, table)`
20-
- paragraph contains: (textelement)+
21-
- text element: choose(unmarked text, markup text, timestamps, footnotes, links, latex fragments)
18+
- element contains: `(directive)* choose(paragraph, drawer, comment, footnote def, list, block, dynamic block, table)` or a bare `(directive)`
19+
- paragraph contains: `(expr)+`
20+
- expr contains: anonymous nodes for 'str', 'num', 'sym', and any ascii symbol that is not letters or numbers. (See top of grammar.js and queries for details)
2221

2322
Like in many regex systems, `*/+` is read as "0/1 or more", and `?` is 0 or 1.
2423

@@ -46,54 +45,86 @@ Text
4645
Parses as:
4746
```
4847
(document [0, 0] - [16, 0]
49-
(directive [0, 0] - [1, 0]
50-
name: (name [0, 2] - [0, 7])
51-
value: (value [0, 9] - [0, 16]))
52-
(body [2, 0] - [3, 0]
48+
(body [0, 0] - [4, 0]
49+
directive: (directive [0, 0] - [1, 0]
50+
name: (expr [0, 2] - [0, 7])
51+
value: (value [0, 9] - [0, 16]
52+
(expr [0, 9] - [0, 16])))
5353
(paragraph [2, 0] - [3, 0]
54-
(markup [2, 5] - [2, 16])))
54+
(expr [2, 0] - [2, 4])
55+
(expr [2, 5] - [2, 12])
56+
(expr [2, 13] - [2, 16])
57+
(expr [2, 17] - [2, 22])))
5558
(section [4, 0] - [16, 0]
56-
(headline [4, 0] - [4, 12]
57-
(stars [4, 0] - [4, 1])
58-
(item [4, 2] - [4, 12]))
59+
(headline [4, 0] - [5, 0]
60+
stars: (stars [4, 0] - [4, 1])
61+
item: (item [4, 2] - [4, 12]
62+
(expr [4, 2] - [4, 6])
63+
(expr [4, 7] - [4, 12])))
5964
(plan [5, 0] - [6, 0]
60-
(timestamp [5, 0] - [5, 16]
61-
(date [5, 1] - [5, 15])))
62-
(body [7, 0] - [11, 10]
63-
(list [7, 0] - [11, 10]
64-
(listitem [7, 3] - [7, 10])
65-
(listitem [8, 3] - [10, 16]
66-
(list [9, 0] - [10, 16]
67-
(listitem [9, 5] - [9, 16])
68-
(listitem [10, 5] - [10, 16])))
69-
(listitem [11, 3] - [11, 10])))
65+
(entry [5, 0] - [5, 16]
66+
timestamp: (timestamp [5, 0] - [5, 16]
67+
(date [5, 1] - [5, 11])
68+
(day [5, 12] - [5, 15]))))
69+
(body [6, 0] - [13, 0]
70+
(list [7, 0] - [12, 0]
71+
(listitem [7, 2] - [8, 0]
72+
bullet: (bullet [7, 2] - [7, 3])
73+
contents: (paragraph [7, 4] - [8, 0]
74+
(expr [7, 4] - [7, 8])
75+
(expr [7, 9] - [7, 10])))
76+
(listitem [8, 2] - [11, 0]
77+
bullet: (bullet [8, 2] - [8, 3])
78+
contents: (paragraph [8, 4] - [9, 0]
79+
(expr [8, 4] - [8, 5])
80+
(expr [8, 6] - [8, 7])
81+
(expr [8, 8] - [8, 12])
82+
(expr [8, 13] - [8, 14]))
83+
contents: (list [9, 0] - [11, 0]
84+
(listitem [9, 4] - [10, 0]
85+
bullet: (bullet [9, 4] - [9, 5])
86+
contents: (paragraph [9, 6] - [10, 0]
87+
(expr [9, 6] - [9, 7])
88+
(expr [9, 8] - [9, 9])
89+
(expr [9, 10] - [9, 14])
90+
(expr [9, 15] - [9, 16])))
91+
(listitem [10, 4] - [11, 0]
92+
bullet: (bullet [10, 4] - [10, 5])
93+
contents: (paragraph [10, 6] - [11, 0]
94+
(expr [10, 6] - [10, 7])
95+
(expr [10, 8] - [10, 9])
96+
(expr [10, 10] - [10, 14])
97+
(expr [10, 15] - [10, 16])))))
98+
(listitem [11, 2] - [12, 0]
99+
bullet: (bullet [11, 2] - [11, 3])
100+
contents: (paragraph [11, 4] - [12, 0]
101+
(expr [11, 4] - [11, 8])
102+
(expr [11, 9] - [11, 10])))))
70103
(section [13, 0] - [16, 0]
71-
(headline [13, 0] - [13, 19]
72-
(stars [13, 0] - [13, 2])
73-
(item [13, 3] - [13, 13])
74-
tags: (tag [13, 15] - [13, 18]))
75-
(body [15, 0] - [16, 0]
76-
(paragraph [15, 0] - [16, 0])))))
104+
(headline [13, 0] - [14, 0]
105+
stars: (stars [13, 0] - [13, 2])
106+
item: (item [13, 3] - [13, 13]
107+
(expr [13, 3] - [13, 13]))
108+
tags: (tag_list [13, 14] - [13, 19]
109+
tag: (tag [13, 15] - [13, 18])))
110+
(body [14, 0] - [16, 0]
111+
(paragraph [15, 0] - [16, 0]
112+
(expr [15, 0] - [15, 4]))))))
77113
```
78114

79115
## Install
80116

81-
To compile the parser library for use in neovim & others:
82-
83-
`gcc -o org.so -I./src src/parser.c src/scanner.cc -shared -Os -lstdc++`
84-
85-
`cp org.so NEOVIMDIR/parser/`
117+
For manual install, use `make`.
86118

87-
For neovim, using `nvim-treesitter/nvim-treesitter`:
88-
89-
Add to your init.lua (or otherwise source):
119+
For neovim, using `nvim-treesitter/nvim-treesitter`, add to your configuration:
90120

91121
``` lua
92122
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
93123
parser_config.org = {
94124
install_info = {
95-
url = '<PREFIX>/tree-sitter-org',
96-
files = {'src/parser.c', 'src/scanner.cc'},
125+
url = 'https://github.com/milisims/tree-sitter-org',
126+
revision = 'main',
127+
files = { 'src/parser.c', 'src/scanner.cc' },
97128
},
98129
filetype = 'org',
99130
}
@@ -105,4 +136,3 @@ To build the parser using npm and run tests:
105136
2. Clone this repository: `git clone https://github.com/milisims/tree-sitter-org` and `cd` into it
106137
3. Install tree-sitter using npm: `npm install`
107138
4. Run tests: `./node_modules/.bin/tree-sitter generate && ./node_modules/.bin/tree-sitter test`
108-

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tree-sitter-org",
3-
"version": "0.0.1",
3+
"version": "1.0.0",
44
"description": "Org grammar for tree-sitter",
55
"main": "bindings/node",
66
"keywords": [

0 commit comments

Comments
 (0)