Skip to content

Commit

Permalink
fix: make stage3 objects have a Vec<ParagraphSegment> instead of `V…
Browse files Browse the repository at this point in the history
…ec<ParagraphSegmentToken>` for title
  • Loading branch information
vhyrro committed Aug 22, 2024
1 parent 7a34faf commit 07a2294
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 53 deletions.
6 changes: 4 additions & 2 deletions src/snapshots/rust_norg__tests__definitions.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ expression: examples
- - RangeableDetachedModifier:
modifier_type: Definition
title:
- Text: Term
- Token:
Text: Term
extensions: []
content:
- Paragraph:
Expand All @@ -14,7 +15,8 @@ expression: examples
- - RangeableDetachedModifier:
modifier_type: Definition
title:
- Text: Term
- Token:
Text: Term
extensions: []
content:
- Paragraph:
Expand Down
6 changes: 4 additions & 2 deletions src/snapshots/rust_norg__tests__footnotes.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ expression: examples
- - RangeableDetachedModifier:
modifier_type: Footnote
title:
- Text: Title
- Token:
Text: Title
extensions: []
content:
- Paragraph:
Expand All @@ -14,7 +15,8 @@ expression: examples
- - RangeableDetachedModifier:
modifier_type: Footnote
title:
- Text: Title
- Token:
Text: Title
extensions: []
content:
- Paragraph:
Expand Down
71 changes: 45 additions & 26 deletions src/snapshots/rust_norg__tests__headings.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ expression: examples
- - Heading:
level: 1
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- - Heading:
level: 9
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- - Heading:
level: 1
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- Paragraph:
- Token:
Expand All @@ -25,45 +28,56 @@ expression: examples
- - Heading:
level: 7
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- - Heading:
level: 1
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- Heading:
level: 1
title:
- Text: Another
- Whitespace
- Text: heading
- Token:
Text: Another
- Token: Whitespace
- Token:
Text: heading
extensions: []
- - Heading:
level: 1
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- Heading:
level: 2
title:
- Text: Subheading
- Token:
Text: Subheading
extensions: []
- Heading:
level: 1
title:
- Text: Back
- Whitespace
- Text: to
- Whitespace
- Text: regular
- Whitespace
- Text: heading
- Token:
Text: Back
- Token: Whitespace
- Token:
Text: to
- Token: Whitespace
- Token:
Text: regular
- Token: Whitespace
- Token:
Text: heading
extensions: []
- - Heading:
level: 1
title:
- Text: Heading
- Token:
Text: Heading
extensions: []
- Paragraph:
- Token:
Expand All @@ -76,7 +90,8 @@ expression: examples
- Heading:
level: 2
title:
- Text: Subheading
- Token:
Text: Subheading
extensions: []
- Paragraph:
- Token:
Expand All @@ -95,11 +110,15 @@ expression: examples
- Heading:
level: 1
title:
- Text: Back
- Whitespace
- Text: to
- Whitespace
- Text: regular
- Whitespace
- Text: heading
- Token:
Text: Back
- Token: Whitespace
- Token:
Text: to
- Token: Whitespace
- Token:
Text: regular
- Token: Whitespace
- Token:
Text: heading
extensions: []
44 changes: 28 additions & 16 deletions src/snapshots/rust_norg__tests__ranged_tags.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ expression: examples
- Heading:
level: 1
title:
- Text: Hello
- Whitespace
- Text: world
- Special: "!"
- Token:
Text: Hello
- Token: Whitespace
- Token:
Text: world
- Token:
Special: "!"
extensions: []
- - RangedTag:
name:
Expand All @@ -85,10 +88,13 @@ expression: examples
- Heading:
level: 1
title:
- Text: Hello
- Whitespace
- Text: world
- Special: "!"
- Token:
Text: Hello
- Token: Whitespace
- Token:
Text: world
- Token:
Special: "!"
extensions: []
- - RangedTag:
name:
Expand Down Expand Up @@ -155,10 +161,13 @@ expression: examples
- Heading:
level: 1
title:
- Text: Hello
- Whitespace
- Text: world
- Special: "!"
- Token:
Text: Hello
- Token: Whitespace
- Token:
Text: world
- Token:
Special: "!"
extensions: []
- - RangedTag:
name:
Expand All @@ -173,8 +182,11 @@ expression: examples
- Heading:
level: 1
title:
- Text: Hello
- Whitespace
- Text: world
- Special: "!"
- Token:
Text: Hello
- Token: Whitespace
- Token:
Text: world
- Token:
Special: "!"
extensions: []
6 changes: 4 additions & 2 deletions src/snapshots/rust_norg__tests__tables.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ expression: examples
- - RangeableDetachedModifier:
modifier_type: Table
title:
- Text: A1
- Token:
Text: A1
extensions: []
content:
- Paragraph:
Expand All @@ -17,7 +18,8 @@ expression: examples
- - RangeableDetachedModifier:
modifier_type: Table
title:
- Text: A1
- Token:
Text: A1
extensions: []
content:
- Paragraph:
Expand Down
10 changes: 5 additions & 5 deletions src/stage_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,13 @@ pub enum NorgASTFlat {
},
RangeableDetachedModifier {
modifier_type: RangeableDetachedModifier,
title: ParagraphTokenList,
title: Vec<ParagraphSegment>,
extensions: Vec<DetachedModifierExtension>,
content: Vec<Self>,
},
Heading {
level: u16,
title: ParagraphTokenList,
title: Vec<ParagraphSegment>,
extensions: Vec<DetachedModifierExtension>,
},
CarryoverTag {
Expand Down Expand Up @@ -636,7 +636,7 @@ pub fn stage_3(
NorgBlock::RangeableDetachedModifier { modifier_type: ':', ranged: false, title, extension_section } => (RangeableDetachedModifier::Table, title, extension_section),
}.then(paragraph).map(|((modifier_type, title, extension_section), paragraph)| NorgASTFlat::RangeableDetachedModifier {
modifier_type,
title,
title: parse_paragraph(title).unwrap(),
extensions: detached_modifier_extensions().parse(extension_section).unwrap_or_default(),
content: vec![paragraph],
});
Expand All @@ -652,7 +652,7 @@ pub fn stage_3(
if opening_ch == closing_ch {
Ok(NorgASTFlat::RangeableDetachedModifier {
modifier_type,
title,
title: parse_paragraph(title).unwrap(),
extensions: detached_modifier_extensions().parse(extension_section).unwrap_or_default(),
content,
})
Expand All @@ -665,7 +665,7 @@ pub fn stage_3(
}
.try_map(move |(level, title, extension_section), _span| Ok(NorgASTFlat::Heading {
level,
title,
title: parse_paragraph(title).unwrap(),
extensions: detached_modifier_extensions().parse(extension_section).unwrap_or_default(),
}));

Expand Down

0 comments on commit 07a2294

Please sign in to comment.