Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: attached modifiers #5

Merged
merged 11 commits into from
Aug 14, 2024
1 change: 1 addition & 0 deletions proptest-regressions/lib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# everyone who runs the test benefits from these saved cases.
cc fb9b5df4fe46fe331cc3aa40bba6501c1c603084688fd02dda6d1c73106c1324 # shrinks to tag_name = "A", parameter = "A", multi_parameter = "\u{b}"
cc 28afae9872324ba0632a8023219e32939580363ce8b99752dc19fae0ac5b63d1 # shrinks to paragraph_content = " "
cc 5b31c9987c98fc0e4faa50b782e5952e0948d2c2a60dd29081c8f54c75b4b52c # shrinks to tag_name = "ø", parameter = "a", multi_parameter = " "
47 changes: 47 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,51 @@ mod tests {
parse(&paragraph_content).unwrap();
}
}

#[test]
fn modifiers() {
let examples: Vec<_> = [
"this *is* a test",
"hello, *world*!",
"*hello, world!*",
"*hello*, world!",
"*/hello/*, world!",
"*hi!* how are you?",
"this *is a test",
"this *is/ a test",
"this *is*/ a test",
"this */is/*/ a test",
]
.into_iter()
.map(|example| example.to_string() + "\n")
.map(|str| parse(&str))
.try_collect()
.unwrap();

assert_yaml_snapshot!(examples);
}

#[test]
fn links() {
let examples: Vec<_> = [
"{https://github.com/nvim-neorg/neorg}",
"{$ hello!}",
"{/ a-path.txt}",
"{********* hello!}",
"{:/some/file:*** a -path-.txt}",
"[anchor]",
"[anchor][description]",
"{* hello}[description]",
"[description]{* hello}",
"This is a <link>!",
"<*linkable with markup*> here!",
]
.into_iter()
.map(|example| example.to_string() + "\n")
.map(|str| parse(&str))
.try_collect()
.unwrap();

assert_yaml_snapshot!(examples);
}
}
38 changes: 25 additions & 13 deletions src/snapshots/rust_norg__tests__carryover_tags.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/main.rs
source: src/lib.rs
expression: examples
---
- - CarryoverTag:
Expand All @@ -9,15 +9,17 @@ expression: examples
parameters: []
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Attribute
name:
- tag-name_with-complexchars
parameters: []
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Attribute
name:
Expand All @@ -26,7 +28,8 @@ expression: examples
- parameter
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Attribute
name:
Expand All @@ -35,7 +38,8 @@ expression: examples
- one large parameter
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Attribute
name:
Expand All @@ -47,7 +51,8 @@ expression: examples
- parameter
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Attribute
name:
Expand All @@ -58,23 +63,26 @@ expression: examples
- "https://github.com/super-special/repo.git?text=hello&other_text=bye"
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Macro
name:
- tag
parameters: []
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Macro
name:
- tag-name_with-complexchars
parameters: []
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Macro
name:
Expand All @@ -83,7 +91,8 @@ expression: examples
- parameter
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Macro
name:
Expand All @@ -92,7 +101,8 @@ expression: examples
- one large parameter
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Macro
name:
Expand All @@ -104,7 +114,8 @@ expression: examples
- parameter
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
- - CarryoverTag:
tag_type: Macro
name:
Expand All @@ -115,4 +126,5 @@ expression: examples
- "https://github.com/super-special/repo.git?text=hello&other_text=bye"
next_object:
Paragraph:
- Text: paragraph
- Token:
Text: paragraph
13 changes: 8 additions & 5 deletions src/snapshots/rust_norg__tests__definitions.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/main.rs
source: src/lib.rs
expression: examples
---
- - RangeableDetachedModifier:
Expand All @@ -9,14 +9,17 @@ expression: examples
extensions: []
content:
- Paragraph:
- Text: Definition
- Token:
Text: Definition
- - RangeableDetachedModifier:
modifier_type: Definition
title:
- Text: Term
extensions: []
content:
- Paragraph:
- Text: Long
- Whitespace
- Text: definition
- Token:
Text: Long
- Token: Whitespace
- Token:
Text: definition
13 changes: 8 additions & 5 deletions src/snapshots/rust_norg__tests__footnotes.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/main.rs
source: src/lib.rs
expression: examples
---
- - RangeableDetachedModifier:
Expand All @@ -9,14 +9,17 @@ expression: examples
extensions: []
content:
- Paragraph:
- Text: Content
- Token:
Text: Content
- - RangeableDetachedModifier:
modifier_type: Footnote
title:
- Text: Title
extensions: []
content:
- Paragraph:
- Text: Long
- Whitespace
- Text: content
- Token:
Text: Long
- Token: Whitespace
- Token:
Text: content
40 changes: 25 additions & 15 deletions src/snapshots/rust_norg__tests__headings.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/main.rs
source: src/lib.rs
expression: examples
---
- - Heading:
Expand All @@ -18,8 +18,10 @@ expression: examples
- Text: Heading
extensions: []
- Paragraph:
- Text: content
- Special: "."
- Token:
Text: content
- Token:
Special: "."
- - Heading:
level: 7
title:
Expand Down Expand Up @@ -64,24 +66,32 @@ expression: examples
- Text: Heading
extensions: []
- Paragraph:
- Text: sneaky
- Whitespace
- Text: content
- Special: "."
- Token:
Text: sneaky
- Token: Whitespace
- Token:
Text: content
- Token:
Special: "."
- Heading:
level: 2
title:
- Text: Subheading
extensions: []
- Paragraph:
- Text: more
- Whitespace
- Text: sneaky
- Whitespace
- Text: content
- Whitespace
- Text: inside
- Special: "."
- Token:
Text: more
- Token: Whitespace
- Token:
Text: sneaky
- Token: Whitespace
- Token:
Text: content
- Token: Whitespace
- Token:
Text: inside
- Token:
Special: "."
- Heading:
level: 1
title:
Expand Down
Loading