https://github.com/milisims/tree-sitter-org Skip to content Sign up * Product + Features + Mobile + Actions + Codespaces + Packages + Security + Code review + Issues + Integrations + GitHub Sponsors + Customer stories * Team * Enterprise * Explore + Explore GitHub + Learn and contribute + Topics + Collections + Trending + Learning Lab + Open source guides + Connect with others + The ReadME Project + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing + Plans + Compare plans + Contact Sales + Education [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} milisims / tree-sitter-org Public * Notifications * Fork 7 * Star 79 Org grammar for tree-sitter MIT License 79 stars 7 forks Star Notifications * Code * Issues 0 * Pull requests 1 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 1 branch 5 tags Code Latest commit @milisims milisims chore!: Version 1.0.0 ... fab7af3 Apr 7, 2022 chore!: Version 1.0.0 fab7af3 Git stats * 62 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time bindings Add build and generated files Jul 19, 2021 corpus fix: link in plan line parses correctly as paragraph Apr 5, 2022 queries feat!: match elements in list items, remove (itemtext) Mar 28, 2022 src fix: link in plan line parses correctly as paragraph Apr 5, 2022 .gitignore Initial commit Apr 11, 2021 Cargo.toml chore!: Version 1.0.0 Apr 7, 2022 LICENSE chore!: Version 1.0.0 Apr 7, 2022 README.md chore!: Version 1.0.0 Apr 7, 2022 binding.gyp Fix npm install Jul 21, 2021 grammar.js fix: link in plan line parses correctly as paragraph Apr 5, 2022 package.json chore!: Version 1.0.0 Apr 7, 2022 View code tree-sitter-org Overview Example Install README.md tree-sitter-org Org grammar for tree-sitter. Here, the goal is to implement a grammar that can usefully parse org files to be used in any library that uses tree-sitter parsers. It is not meant to implement emacs' orgmode parser exactly, which is inherently more dynamic than tree-sitter easily allows. Overview This section is meant to be a quick reference, not a thorough description. Refer to the tests in corpus for examples. * Top level node: (document) * Document contains: (directive)* (body)? (section)* * Section contains: (headline) (plan)? (property_drawer)? (body)? * headline contains: ((stars), (item)?, (tag_list)?) * body contains: (element)+ * element contains: (directive)* choose(paragraph, drawer, comment, footnote def, list, block, dynamic block, table) or a bare (directive) * paragraph contains: (expr)+ * 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) Like in many regex systems, */+ is read as "0/1 or more", and ? is 0 or 1. Example #+TITLE: Example Some *marked up* words * TODO Title <2020-06-07 Sun> - list a - [ ] list a - [ ] list b - [ ] list b - list a ** Subsection :tag: Text Parses as: (document [0, 0] - [16, 0] (body [0, 0] - [4, 0] directive: (directive [0, 0] - [1, 0] name: (expr [0, 2] - [0, 7]) value: (value [0, 9] - [0, 16] (expr [0, 9] - [0, 16]))) (paragraph [2, 0] - [3, 0] (expr [2, 0] - [2, 4]) (expr [2, 5] - [2, 12]) (expr [2, 13] - [2, 16]) (expr [2, 17] - [2, 22]))) (section [4, 0] - [16, 0] (headline [4, 0] - [5, 0] stars: (stars [4, 0] - [4, 1]) item: (item [4, 2] - [4, 12] (expr [4, 2] - [4, 6]) (expr [4, 7] - [4, 12]))) (plan [5, 0] - [6, 0] (entry [5, 0] - [5, 16] timestamp: (timestamp [5, 0] - [5, 16] (date [5, 1] - [5, 11]) (day [5, 12] - [5, 15])))) (body [6, 0] - [13, 0] (list [7, 0] - [12, 0] (listitem [7, 2] - [8, 0] bullet: (bullet [7, 2] - [7, 3]) contents: (paragraph [7, 4] - [8, 0] (expr [7, 4] - [7, 8]) (expr [7, 9] - [7, 10]))) (listitem [8, 2] - [11, 0] bullet: (bullet [8, 2] - [8, 3]) contents: (paragraph [8, 4] - [9, 0] (expr [8, 4] - [8, 5]) (expr [8, 6] - [8, 7]) (expr [8, 8] - [8, 12]) (expr [8, 13] - [8, 14])) contents: (list [9, 0] - [11, 0] (listitem [9, 4] - [10, 0] bullet: (bullet [9, 4] - [9, 5]) contents: (paragraph [9, 6] - [10, 0] (expr [9, 6] - [9, 7]) (expr [9, 8] - [9, 9]) (expr [9, 10] - [9, 14]) (expr [9, 15] - [9, 16]))) (listitem [10, 4] - [11, 0] bullet: (bullet [10, 4] - [10, 5]) contents: (paragraph [10, 6] - [11, 0] (expr [10, 6] - [10, 7]) (expr [10, 8] - [10, 9]) (expr [10, 10] - [10, 14]) (expr [10, 15] - [10, 16]))))) (listitem [11, 2] - [12, 0] bullet: (bullet [11, 2] - [11, 3]) contents: (paragraph [11, 4] - [12, 0] (expr [11, 4] - [11, 8]) (expr [11, 9] - [11, 10]))))) (section [13, 0] - [16, 0] (headline [13, 0] - [14, 0] stars: (stars [13, 0] - [13, 2]) item: (item [13, 3] - [13, 13] (expr [13, 3] - [13, 13])) tags: (tag_list [13, 14] - [13, 19] tag: (tag [13, 15] - [13, 18]))) (body [14, 0] - [16, 0] (paragraph [15, 0] - [16, 0] (expr [15, 0] - [15, 4])))))) Install For manual install, use make. For neovim, using nvim-treesitter/nvim-treesitter, add to your configuration: local parser_config = require "nvim-treesitter.parsers".get_parser_configs() parser_config.org = { install_info = { url = 'https://github.com/milisims/tree-sitter-org', revision = 'main', files = { 'src/parser.c', 'src/scanner.cc' }, }, filetype = 'org', } To build the parser using npm and run tests: 1. Install node.js as described in the tree-sitter documentation 2. Clone this repository: git clone https://github.com/milisims/ tree-sitter-org and cd into it 3. Install tree-sitter using npm: npm install 4. Run tests: ./node_modules/.bin/tree-sitter generate && ./ node_modules/.bin/tree-sitter test About Org grammar for tree-sitter Resources Readme License MIT License Stars 79 stars Watchers 4 watching Forks 7 forks Releases 5 tags Packages 0 No packages published Contributors 3 * @milisims milisims Emilia Simmons * @kristijanhusak kristijanhusak Kristijan Husak * @lukas-reineke lukas-reineke Lukas Reineke Languages * C 96.3% * Scilab 2.3% * JavaScript 0.5% * C++ 0.4% * Scheme 0.3% * Rust 0.2% * (c) 2022 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.