diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-01-30 12:50:58 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-01-30 22:46:59 +0100 |
| commit | 8d1ce390e21ce0a5812a4211c893ec359906d6f1 (patch) | |
| tree | 5dbe1ad96af8ce8f9f01887340fe06025462e959 /src/library | |
| parent | d7072f378fef733ae994fd9a1e767df4e4dd878e (diff) | |
Rework strong and emph
- Star and underscore not parsed as strong/emph inside of words
- Stars/underscores must be balanced and they cannot go over paragraph break
- New `strong` and `emph` classes
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/mod.rs | 2 | ||||
| -rw-r--r-- | src/library/text.rs | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/library/mod.rs b/src/library/mod.rs index 44f8f947..3115cc7a 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -93,6 +93,8 @@ pub fn new() -> Scope { std.def_class::<ParbreakNode>("parbreak"); std.def_class::<LinebreakNode>("linebreak"); std.def_class::<TextNode>("text"); + std.def_class::<StrongNode>("strong"); + std.def_class::<EmphNode>("emph"); std.def_class::<DecoNode<Underline>>("underline"); std.def_class::<DecoNode<Strikethrough>>("strike"); std.def_class::<DecoNode<Overline>>("overline"); diff --git a/src/library/text.rs b/src/library/text.rs index b8810ac6..6d7be323 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -150,6 +150,26 @@ impl Debug for TextNode { } } +/// Strong text, rendered in boldface. +pub struct StrongNode; + +#[class] +impl StrongNode { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + Ok(args.expect::<Node>("body")?.styled(TextNode::STRONG, true)) + } +} + +/// Emphasized text, rendered with an italic face. +pub struct EmphNode; + +#[class] +impl EmphNode { + fn construct(_: &mut EvalContext, args: &mut Args) -> TypResult<Node> { + Ok(args.expect::<Node>("body")?.styled(TextNode::EMPH, true)) + } +} + /// A generic or named font family. #[derive(Clone, Eq, PartialEq, Hash)] pub enum FontFamily { |
