summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-11-19 20:17:43 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-11-19 20:19:01 +0000
commitc82b272d55af6d7da6bb99073378a84adc492408 (patch)
tree77cfba6488812082de4e427d9a368d0e188237cf /src
parentcc938c5829a53b847e30fe6802e56e3fbaafd2ef (diff)
downloadsubplot-c82b272d55af6d7da6bb99073378a84adc492408.tar.gz
ast: Build images into the partial AST
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src')
-rw-r--r--src/ast.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 7584acc..3840e0e 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -148,7 +148,7 @@ fn parse_blocks(markdown: &str) -> Vec<Block> {
Tag::Paragraph => blocks.push(paragraph(&mut inlines)),
Tag::Heading(level) => blocks.push(heading(level as i64, &mut inlines)),
Tag::CodeBlock(kind) => blocks.push(code_block(&kind, &mut inlines)),
-
+ Tag::Image(_link, dest, title) => blocks.push(image_block(&dest, &title)),
// We don't handle anything else yet.
_ => (),
},
@@ -180,6 +180,15 @@ fn heading(level: i64, inlines: &mut Vec<Inline>) -> Block {
Block::Header(level, attr, std::mem::take(inlines))
}
+fn image_block(dest: &str, title: &str) -> Block {
+ let attr = ("".to_string(), vec![], vec![]);
+ Block::Para(vec![Inline::Image(
+ attr,
+ vec![],
+ (dest.to_string(), title.to_string()),
+ )])
+}
+
fn code_block(kind: &CodeBlockKind, inlines: &mut Vec<Inline>) -> Block {
event!(Level::TRACE, ?kind, "code block");
let attr = if let CodeBlockKind::Fenced(lang) = kind {