Update readme parse example + install instructions

This commit is contained in:
Emilia Simmons 2021-08-20 08:56:05 -04:00
parent 3b19be0cf3
commit 3551d82a28

View file

@ -46,17 +46,17 @@ Text
Parses as:
```
(document [0, 0] - [16, 0]
(directive [0, 0] - [0, 16]
(directive [0, 0] - [1, 0]
name: (name [0, 2] - [0, 7])
value: (value [0, 9] - [0, 16]))
(body [2, 0] - [2, 22]
(paragraph [2, 0] - [2, 22]
(bold [2, 5] - [2, 16])))
(section [4, 1] - [16, 0]
(headline [4, 1] - [4, 12]
(stars [4, 1] - [4, 1])
(body [2, 0] - [3, 0]
(paragraph [2, 0] - [3, 0]
(markup [2, 5] - [2, 16])))
(section [4, 0] - [16, 0]
(headline [4, 0] - [4, 12]
(stars [4, 0] - [4, 1])
(item [4, 2] - [4, 12]))
plan: (plan [5, 0] - [5, 16]
(plan [5, 0] - [6, 0]
(timestamp [5, 0] - [5, 16]
(date [5, 1] - [5, 15])))
(body [7, 0] - [11, 10]
@ -67,13 +67,13 @@ Parses as:
(listitem [9, 5] - [9, 16])
(listitem [10, 5] - [10, 16])))
(listitem [11, 3] - [11, 10])))
(section [13, 2] - [16, 0]
(headline [13, 2] - [13, 19]
(stars [13, 2] - [13, 2])
(section [13, 0] - [16, 0]
(headline [13, 0] - [13, 19]
(stars [13, 0] - [13, 2])
(item [13, 3] - [13, 13])
tags: (tag [13, 15] - [13, 18]))
(body [15, 0] - [15, 4]
(paragraph [15, 0] - [15, 4])))))
(body [15, 0] - [16, 0]
(paragraph [15, 0] - [16, 0])))))
```
## Install
@ -82,19 +82,27 @@ To compile the parser library for use in neovim & others:
`gcc -o org.so -I./src src/parser.c src/scanner.cc -shared -Os -lstdc++`
`cp org.so NEOVIMDIR/parser/`
For neovim, using `nvim-treesitter/nvim-treesitter`:
Add to your init.lua (or otherwise source):
``` lua
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.org = {
install_info = {
url = '<PREFIX>/tree-sitter-org',
files = {'src/parser.c', 'src/scanner.cc'},
},
filetype = 'org',
}
```
To build the parser using npm and run tests:
1. Install node.js as mentioned in the [tree-sitter documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers#dependencies)
1. Install node.js as described in the [tree-sitter documentation](https://tree-sitter.github.io/tree-sitter/creating-parsers#dependencies)
2. Clone this repository: `git clone https://github.com/milisims/tree-sitter-org` and `cd` into it
2. Install tree-sitter using npm: `npm install tree-sitter-cli`
3. Install tree-sitter using npm: `npm install`
4. Run tests: `./node_modules/.bin/tree-sitter generate && ./node_modules/.bin/tree-sitter test`
## TODO
- Use generic markup instead of types of markup
For example: *a b c* should be `(markup type: *)`, where type is a field, instead of `(bold)` .
Allows users to more clearly use markup as they see fit.
- Fix textelements within list items
- Fix other tests -- mostly dynamic priority issues with paragraphs
- Add more fields where appropriate. Note: it's easy to query for a _missing_ field