summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-04-17 13:09:41 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-05-09 15:44:59 -0400
commit72cd5a8a94100054b27848e0ed62f8bb0962e488 (patch)
tree5f1acbcdabd06aa2d5151548cddff2ac170f9282 /test
add tree-sitter grammar for SiSU Spine markup
Tree-sitter parser for .sst/.ssm/.ssi document markup files. Parses headers, headings, block elements (code, poem, block, group, table, quote - both curly and tic syntax), inline formatting (10 types, recursive/nestable), footnotes, editor notes, links, images, book index entries, and special markers. Includes external scanner for raw block content, highlight queries for syntax coloring, fold queries, 67 test cases, and project configuration for tree-sitter CLI. Tested against sample documents: error-free on Alice in Wonderland (1877 lines), Wealth of Networks (5833 lines), GPL v3 (297 lines). Known limitation: multi-line footnotes that wrap across physical lines. (assisted by Claude-Code) Co-Authored-By: Claude Opus 4.6 (1M context)
Diffstat (limited to 'test')
-rw-r--r--test/corpus/blocks.txt144
-rw-r--r--test/corpus/book_index.txt73
-rw-r--r--test/corpus/footnotes.txt94
-rw-r--r--test/corpus/headers.txt98
-rw-r--r--test/corpus/headings.txt171
-rw-r--r--test/corpus/inline_formatting.txt167
-rw-r--r--test/corpus/links.txt78
-rw-r--r--test/corpus/paragraphs.txt76
-rw-r--r--test/corpus/special_markers.txt71
9 files changed, 972 insertions, 0 deletions
diff --git a/test/corpus/blocks.txt b/test/corpus/blocks.txt
new file mode 100644
index 0000000..b47a8c9
--- /dev/null
+++ b/test/corpus/blocks.txt
@@ -0,0 +1,144 @@
+==================
+Code block curly brace
+==================
+
+code{
+
+some code here
+
+}code
+
+---
+
+(document
+ (code_block_curly
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Code block tic syntax
+==================
+
+``` code
+some code here
+```
+
+---
+
+(document
+ (code_block_tic
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Poem block curly
+==================
+
+poem{
+
+First verse here.
+
+Second verse here.
+
+}poem
+
+---
+
+(document
+ (poem_block_curly
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Block block curly
+==================
+
+block{
+
+Preserved whitespace content.
+
+}block
+
+---
+
+(document
+ (block_block_curly
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Group block curly
+==================
+
+group{
+
+Grouped content here.
+
+}group
+
+---
+
+(document
+ (group_block_curly
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Table block curly with spec
+==================
+
+table(c3: 40, 30, 30){
+
+cell1
+cell2
+cell3
+
+}table
+
+---
+
+(document
+ (table_block_curly
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Quote block tic
+==================
+
+``` quote
+Quoted text here.
+```
+
+---
+
+(document
+ (quote_block_tic
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
+
+==================
+Numbered code block
+==================
+
+code(number){
+
+line one
+line two
+
+}code
+
+---
+
+(document
+ (code_block_curly
+ open: (block_open)
+ content: (raw_content)
+ close: (block_close)))
diff --git a/test/corpus/book_index.txt b/test/corpus/book_index.txt
new file mode 100644
index 0000000..f1b4d12
--- /dev/null
+++ b/test/corpus/book_index.txt
@@ -0,0 +1,73 @@
+==================
+Single term index
+==================
+
+={ democracy }
+
+---
+
+(document
+ (book_index
+ (index_content)))
+
+==================
+Multiple terms
+==================
+
+={ democracy ; freedom of speech ; public domain }
+
+---
+
+(document
+ (book_index
+ (index_content)))
+
+==================
+Term with sub-term
+==================
+
+={ copyright law : duration of }
+
+---
+
+(document
+ (book_index
+ (index_content)))
+
+==================
+Term with span
+==================
+
+={ animated cartoons +15 }
+
+---
+
+(document
+ (book_index
+ (index_content)))
+
+==================
+Multiple sub-terms with pipe
+==================
+
+={ public domain : defined | traditional contours of }
+
+---
+
+(document
+ (book_index
+ (index_content)))
+
+==================
+Complex multi-line index
+==================
+
+={ animated cartoons +15 ;
+ Steamboat Willie +9
+}
+
+---
+
+(document
+ (book_index
+ (index_content)))
diff --git a/test/corpus/footnotes.txt b/test/corpus/footnotes.txt
new file mode 100644
index 0000000..2d5b846
--- /dev/null
+++ b/test/corpus/footnotes.txt
@@ -0,0 +1,94 @@
+==================
+Simple footnote
+==================
+
+Text here~{ This is a footnote. }~ continues.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (footnote
+ (text))
+ (text)))
+
+==================
+Footnote with formatting
+==================
+
+Text~{ A footnote with /{italic}/ text. }~ more.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (footnote
+ (text)
+ (italic
+ (text))
+ (text))
+ (text)))
+
+==================
+Unnumbered asterisk footnote
+==================
+
+Text ~{* An unnumbered note. }~ continues.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (footnote
+ (footnote_marker)
+ (text))
+ (text)))
+
+==================
+Double asterisk footnote
+==================
+
+Text ~{** Another unnumbered note. }~ continues.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (footnote
+ (footnote_marker)
+ (text))
+ (text)))
+
+==================
+Editor note with asterisk
+==================
+
+Text ~[* Editor's note here. ]~ continues.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (editor_note
+ (text))
+ (text)))
+
+==================
+Editor note with plus
+==================
+
+Text ~[+ Another editor note. ]~ continues.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (editor_note
+ (text))
+ (text)))
diff --git a/test/corpus/headers.txt b/test/corpus/headers.txt
new file mode 100644
index 0000000..cf4dceb
--- /dev/null
+++ b/test/corpus/headers.txt
@@ -0,0 +1,98 @@
+==================
+Version comment
+==================
+
+# SiSU 8.0
+
+---
+
+(document
+ (version_comment))
+
+==================
+Version comment with spine variant
+==================
+
+# SiSUspine 8.0
+
+---
+
+(document
+ (version_comment))
+
+==================
+Simple header field
+==================
+
+title:
+ main: "Document Title"
+
+---
+
+(document
+ (header_field
+ key: (header_key)
+ (header_continuation)))
+
+==================
+Header field with direct value
+==================
+
+creator:
+ author: "Amissah, Ralph"
+
+---
+
+(document
+ (header_field
+ key: (header_key)
+ (header_continuation)))
+
+==================
+Header comment
+==================
+
+# This is a header comment
+
+---
+
+(document
+ (header_comment))
+
+==================
+Multiple header fields
+==================
+
+title:
+ main: "Test"
+
+creator:
+ author: "Test Author"
+
+---
+
+(document
+ (header_field
+ key: (header_key)
+ (header_continuation))
+ (header_field
+ key: (header_key)
+ (header_continuation)))
+
+==================
+Header field with multiple continuations
+==================
+
+classify:
+ topic_register: "topic:subtopic"
+ subject: "keyword1"
+ keywords: "list"
+
+---
+
+(document
+ (header_field
+ key: (header_key)
+ (header_continuation)
+ (header_continuation)
+ (header_continuation)))
diff --git a/test/corpus/headings.txt b/test/corpus/headings.txt
new file mode 100644
index 0000000..f09f734
--- /dev/null
+++ b/test/corpus/headings.txt
@@ -0,0 +1,171 @@
+==================
+Part heading A
+==================
+
+:A~ Document Title
+
+---
+
+(document
+ (heading
+ (heading_part
+ marker: (part_marker)
+ content: (heading_content))))
+
+==================
+Part heading B
+==================
+
+:B~ Part One
+
+---
+
+(document
+ (heading
+ (heading_part
+ marker: (part_marker)
+ content: (heading_content))))
+
+==================
+Part heading C
+==================
+
+:C~ Section Title
+
+---
+
+(document
+ (heading
+ (heading_part
+ marker: (part_marker)
+ content: (heading_content))))
+
+==================
+Part heading D
+==================
+
+:D~ Subsection
+
+---
+
+(document
+ (heading
+ (heading_part
+ marker: (part_marker)
+ content: (heading_content))))
+
+==================
+Part heading with @title substitution
+==================
+
+:A~ @title @creator
+
+---
+
+(document
+ (heading
+ (heading_part
+ marker: (part_marker)
+ content: (heading_content))))
+
+==================
+Segment heading level 1
+==================
+
+1~ Introduction
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ content: (heading_content))))
+
+==================
+Segment heading level 2
+==================
+
+2~ Background
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ content: (heading_content))))
+
+==================
+Segment heading level 3
+==================
+
+3~ Details
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ content: (heading_content))))
+
+==================
+Named segment heading
+==================
+
+1~intro Introduction
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ name: (segment_name)
+ content: (heading_content))))
+
+==================
+Named segment with underscore
+==================
+
+2~heading_levels Heading Levels
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ name: (segment_name)
+ content: (heading_content))))
+
+==================
+Special section heading (bibliography)
+==================
+
+1~!biblio
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ name: (segment_name))))
+
+==================
+Segment with numbering suppression
+==================
+
+1~preface- Preface
+
+---
+
+(document
+ (heading
+ (heading_segment
+ marker: (segment_marker)
+ name: (segment_name)
+ suppress_numbering: (suppress_marker)
+ content: (heading_content))))
diff --git a/test/corpus/inline_formatting.txt b/test/corpus/inline_formatting.txt
new file mode 100644
index 0000000..e48f9c9
--- /dev/null
+++ b/test/corpus/inline_formatting.txt
@@ -0,0 +1,167 @@
+==================
+Emphasis
+==================
+
+Text with *{emphasis}* here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (emphasis
+ (text))
+ (text)))
+
+==================
+Bold
+==================
+
+Text with !{bold text}! here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (bold
+ (text))
+ (text)))
+
+==================
+Italic
+==================
+
+Text with /{italic text}/ here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (italic
+ (text))
+ (text)))
+
+==================
+Underline
+==================
+
+Text with _{underlined}_ here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (underline
+ (text))
+ (text)))
+
+==================
+Citation
+==================
+
+Text with "{cited text}" here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (citation_mark
+ (text))
+ (text)))
+
+==================
+Superscript
+==================
+
+Text with ^{super}^ here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (superscript
+ (text))
+ (text)))
+
+==================
+Subscript
+==================
+
+Text with ,{sub}, here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (subscript
+ (text))
+ (text)))
+
+==================
+Monospace
+==================
+
+Text with #{code}# here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (monospace_inline
+ (text))
+ (text)))
+
+==================
+Strikethrough
+==================
+
+Text with -{deleted}- here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (strikethrough
+ (text))
+ (text)))
+
+==================
+Inserted
+==================
+
+Text with +{added}+ here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (inserted
+ (text))
+ (text)))
+
+==================
+Nested formatting
+==================
+
+Text with *{emphasis with /{nested italic}/ inside}* here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (emphasis
+ (text)
+ (italic
+ (text))
+ (text))
+ (text)))
diff --git a/test/corpus/links.txt b/test/corpus/links.txt
new file mode 100644
index 0000000..716c960
--- /dev/null
+++ b/test/corpus/links.txt
@@ -0,0 +1,78 @@
+==================
+External link
+==================
+
+See { the website }https://www.example.org/ for details.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (link
+ text: (link_text)
+ target: (url))
+ (text)))
+
+==================
+Internal link
+==================
+
+See { the section }#anchor_name for details.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (link
+ text: (link_text)
+ target: (anchor_ref))
+ (text)))
+
+==================
+Auto-footnote link
+==================
+
+See {~^ the website }https://www.example.org/ for details.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (link
+ (auto_footnote_marker)
+ text: (link_text)
+ target: (url))
+ (text)))
+
+==================
+Image
+==================
+
+Here { photo.png }image is shown.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (image
+ spec: (image_spec))
+ (text)))
+
+==================
+Inline anchor
+==================
+
+Text with *~my_anchor here.
+
+---
+
+(document
+ (paragraph
+ (text)
+ (inline_anchor
+ (anchor_name))
+ (text)))
diff --git a/test/corpus/paragraphs.txt b/test/corpus/paragraphs.txt
new file mode 100644
index 0000000..07b2273
--- /dev/null
+++ b/test/corpus/paragraphs.txt
@@ -0,0 +1,76 @@
+==================
+Simple paragraph
+==================
+
+This is a simple paragraph.
+
+---
+
+(document
+ (paragraph
+ (text)))
+
+==================
+Indented paragraph
+==================
+
+_1 This is indented one step.
+
+---
+
+(document
+ (paragraph
+ (paragraph_prefix)
+ (text)))
+
+==================
+Bullet paragraph
+==================
+
+_* This is a bullet point.
+
+---
+
+(document
+ (paragraph
+ (paragraph_prefix)
+ (text)))
+
+==================
+Indented bullet
+==================
+
+_2* Indented bullet text.
+
+---
+
+(document
+ (paragraph
+ (paragraph_prefix)
+ (text)))
+
+==================
+Bold lead-in
+==================
+
+!_ This has bold lead.
+
+---
+
+(document
+ (paragraph
+ (paragraph_prefix)
+ (text)))
+
+==================
+Hanging indent
+==================
+
+_0_1 First line here.
+
+---
+
+(document
+ (paragraph
+ (paragraph_prefix)
+ (text)))
diff --git a/test/corpus/special_markers.txt b/test/corpus/special_markers.txt
new file mode 100644
index 0000000..a852df8
--- /dev/null
+++ b/test/corpus/special_markers.txt
@@ -0,0 +1,71 @@
+==================
+Body comment
+==================
+
+% This is a comment in the body.
+
+---
+
+(document
+ (body_comment))
+
+==================
+OCN suppress block markers
+==================
+
+--~#
+
+--+#
+
+---
+
+(document
+ (ocn_suppress_open)
+ (ocn_suppress_close))
+
+==================
+Page break
+==================
+
+=\=
+
+---
+
+(document
+ (page_break))
+
+==================
+Horizontal rule
+==================
+
+-..-
+
+---
+
+(document
+ (horizontal_rule))
+
+==================
+Composite include
+==================
+
+<< filename.sst
+
+---
+
+(document
+ (composite_include
+ path: (include_path)))
+
+==================
+OCN suppress inline
+==================
+
+Some text here.~#
+
+---
+
+(document
+ (paragraph
+ (text)
+ (ocn_suppress)))