From e193fcc2bae010f8830818b90dcc99b5cac128b6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 19 Dec 2023 19:23:56 -0500 Subject: [PATCH 01/22] Start applying styles to blog posts. --- default_environment/stylesheet/main.css | 37 +++++++++++++++++++ .../templates/html/blog_post_page.dust | 10 ++--- default_environment/templates/html/main.dust | 6 +-- .../templates/html/page_header.dust | 8 ++-- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index e69de29..387c9d9 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -0,0 +1,37 @@ +:root { + --main-max-width: 800px; +} + +.page_centering { + display: flex; + flex-direction: column; + align-items: center; +} + +.page_header { + width: 100%; + max-width: var(--main-max-width); + border-bottom: 0.2rem solid black; + + .home_link { + font-size: 1.2rem; + font-weight: 600; + text-decoration: none; + } +} + +.main_content { + width: 100%; + max-width: var(--main-max-width); + font-size: 1.2rem; +} + +/* A stand-alone blog post (not in a blog stream). */ +.blog_post { + padding: 1rem 0 3rem 0; +} + +.blog_post_title { + font-size: 2rem; + font-weight: 700; +} diff --git a/default_environment/templates/html/blog_post_page.dust b/default_environment/templates/html/blog_post_page.dust index d846e3e..82cd6d7 100644 --- a/default_environment/templates/html/blog_post_page.dust +++ b/default_environment/templates/html/blog_post_page.dust @@ -1,8 +1,6 @@ -
-
- {?.title}{?.self_link}{.title}{:else}
{.title}
{/.self_link}{/.title} - {! TODO: date? !} -
+
+ {?.title}

{?.self_link}{.title}{:else}{.title}{/.self_link}

{/.title} + {! TODO: date? !} {! TODO: Table of contents? !} @@ -18,4 +16,4 @@ {/.footnotes} {/.footnotes}
- + diff --git a/default_environment/templates/html/main.dust b/default_environment/templates/html/main.dust index 9f0f5ed..d183145 100644 --- a/default_environment/templates/html/main.dust +++ b/default_environment/templates/html/main.dust @@ -6,14 +6,14 @@ {#global_settings.js_files}{/global_settings.js_files} {?global_settings.page_title}{global_settings.page_title}{/global_settings.page_title} - + {#.page_header}{>page_header/}{/.page_header} -
+
{@select key=.type} {@eq value="blog_post_page"}{>blog_post_page/}{/eq} {@eq value="blog_stream"}{>blog_stream/}{/eq} {@none}{!TODO: make this panic!}ERROR: Unrecognized page content type{/none} {/select} -
+ diff --git a/default_environment/templates/html/page_header.dust b/default_environment/templates/html/page_header.dust index f2c3089..d14af84 100644 --- a/default_environment/templates/html/page_header.dust +++ b/default_environment/templates/html/page_header.dust @@ -1,4 +1,4 @@ - + From a29b62563135c1ddc14befbca3114472ff21bb9b Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 19 Dec 2023 20:33:21 -0500 Subject: [PATCH 02/22] Apply a dark background. --- default_environment/stylesheet/main.css | 27 ++++++++++++++++++- .../templates/html/blog_post_page.dust | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 387c9d9..8684fa6 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -1,5 +1,20 @@ :root { --main-max-width: 800px; + --site-background-color: #0a0a0a; + --site-text-color: #fffffc; + --header-divider-color: #6a687a; + --unused-1: #6ccff6; + --unused-2: #84828f; +} + +body { + color: var(--site-text-color); + background-color: var(--site-background-color); + + a:link, a:visited { + /* TODO: Should I use a different color for links? */ + color: var(--site-text-color); + } } .page_centering { @@ -11,12 +26,16 @@ .page_header { width: 100%; max-width: var(--main-max-width); - border-bottom: 0.2rem solid black; + border-bottom: 0.1rem solid var(--header-divider-color); .home_link { font-size: 1.2rem; font-weight: 600; text-decoration: none; + + &:link, &:visited { + color: var(--site-text-color); + } } } @@ -24,6 +43,11 @@ width: 100%; max-width: var(--main-max-width); font-size: 1.2rem; + line-height: 1.2; + + p { + margin: 1rem 0; + } } /* A stand-alone blog post (not in a blog stream). */ @@ -34,4 +58,5 @@ .blog_post_title { font-size: 2rem; font-weight: 700; + padding-bottom: 1rem; } diff --git a/default_environment/templates/html/blog_post_page.dust b/default_environment/templates/html/blog_post_page.dust index 82cd6d7..6ad4bf0 100644 --- a/default_environment/templates/html/blog_post_page.dust +++ b/default_environment/templates/html/blog_post_page.dust @@ -1,5 +1,5 @@
- {?.title}

{?.self_link}{.title}{:else}{.title}{/.self_link}

{/.title} + {?.title}

{.title}

{/.title} {! TODO: date? !} {! TODO: Table of contents? !} From 3968121d54de8c933cb9eab46be35451b593d220 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 19 Dec 2023 20:45:03 -0500 Subject: [PATCH 03/22] Style src blocks. --- default_environment/stylesheet/main.css | 31 +++++++++++++++++-- .../templates/html/src_block.dust | 22 +++++++------ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 8684fa6..fe1ab5f 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -1,15 +1,20 @@ :root { + --unused-1: #6ccff6; --main-max-width: 800px; --site-background-color: #0a0a0a; --site-text-color: #fffffc; --header-divider-color: #6a687a; - --unused-1: #6ccff6; - --unused-2: #84828f; + + --src-block-background-color: #141414; + --src-block-border-color: #84828f; + --src-block-language-color: #0a0a0a; + --src-block-language-background: #84828f; } body { color: var(--site-text-color); background-color: var(--site-background-color); + font-family: source-sans-pro, Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', sans-serif; a:link, a:visited { /* TODO: Should I use a different color for links? */ @@ -48,6 +53,28 @@ body { p { margin: 1rem 0; } + + .src_block { + background: var(--src-block-background-color); + border-radius: 3px; + border: 1px solid var(--src-block-border-color); + font-size: 1rem; + font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace; + + .src_language { + display: inline-block; + color: var(--src-block-language-color); + background: var(--src-block-language-background); + border-radius: 0 0 3px 0; + padding: 0.1rem 0.5rem; + font-size: 0.8rem; + vertical-align: top; + } + + .src_body { + margin: 0.5rem; + } + } } /* A stand-alone blog post (not in a blog stream). */ diff --git a/default_environment/templates/html/src_block.dust b/default_environment/templates/html/src_block.dust index 22e7f33..73a76f4 100644 --- a/default_environment/templates/html/src_block.dust +++ b/default_environment/templates/html/src_block.dust @@ -1,9 +1,13 @@ - - - {#.lines} - - - - {/.lines} - -
{.}
+
+ +
text
+ + + {#.lines} + + + + {/.lines} + +
{.}
+
From 80cdf5166b7dde262b0069651cb5e2ad45fd1c02 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 19 Dec 2023 21:41:41 -0500 Subject: [PATCH 04/22] Style quote blocks, h2, and h3. --- default_environment/stylesheet/main.css | 20 +++++++++++++++++++ .../templates/html/quote_block.dust | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index fe1ab5f..7d4124c 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -9,6 +9,8 @@ --src-block-border-color: #84828f; --src-block-language-color: #0a0a0a; --src-block-language-background: #84828f; + + --quote-block-border-color: #84828f; } body { @@ -75,6 +77,24 @@ body { margin: 0.5rem; } } + + .quote_block { + border-left: 1px solid var(--quote-block-border-color); + padding-left: 1rem; + margin-left: 2rem; + } + + h2 { + font-size: 1.8rem; + font-weight: 600; + padding-bottom: 1rem; + } + + h3 { + font-size: 1.5rem; + font-weight: 500; + padding-bottom: 1rem; + } } /* A stand-alone blog post (not in a blog stream). */ diff --git a/default_environment/templates/html/quote_block.dust b/default_environment/templates/html/quote_block.dust index 4e30b27..aa7d4bd 100644 --- a/default_environment/templates/html/quote_block.dust +++ b/default_environment/templates/html/quote_block.dust @@ -1,3 +1,3 @@ -
{#.children} +
{#.children} {>element/} {/.children}
From 65ed754bfe62ca55c663d0677160c12a5cc5eb6d Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 19 Dec 2023 21:57:33 -0500 Subject: [PATCH 05/22] Space out some elements. --- default_environment/stylesheet/main.css | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 7d4124c..263a200 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -62,6 +62,7 @@ body { border: 1px solid var(--src-block-border-color); font-size: 1rem; font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace; + margin: 1rem 0; .src_language { display: inline-block; @@ -80,20 +81,23 @@ body { .quote_block { border-left: 1px solid var(--quote-block-border-color); - padding-left: 1rem; - margin-left: 2rem; + padding: 0 0 0 1rem; + margin: 1rem 0 1rem 2rem; + } + + h2, h3 { + margin: 1rem 0; + padding-bottom: 0.5rem; } h2 { font-size: 1.8rem; font-weight: 600; - padding-bottom: 1rem; } h3 { font-size: 1.5rem; font-weight: 500; - padding-bottom: 1rem; } } From b5387502871275c9f82f838eff46eb543f5979a8 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 12:04:29 -0500 Subject: [PATCH 06/22] Preserve whitespace in src blocks. --- default_environment/stylesheet/main.css | 4 ++++ default_environment/templates/html/src_block.dust | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 263a200..8b0708a 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -76,6 +76,10 @@ body { .src_body { margin: 0.5rem; + + .src_line { + white-space: pre-wrap; + } } } diff --git a/default_environment/templates/html/src_block.dust b/default_environment/templates/html/src_block.dust index 73a76f4..d8560bb 100644 --- a/default_environment/templates/html/src_block.dust +++ b/default_environment/templates/html/src_block.dust @@ -5,7 +5,7 @@ {#.lines} - {.} + {.} {/.lines} From 5654c40d034bf013969a2c607bc6f34ac4a5f4f1 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 12:07:36 -0500 Subject: [PATCH 07/22] Get the real language for src blocks from the org source. --- default_environment/templates/html/src_block.dust | 5 ++--- src/context/src_block.rs | 2 ++ src/intermediate/src_block.rs | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/default_environment/templates/html/src_block.dust b/default_environment/templates/html/src_block.dust index d8560bb..f0a6357 100644 --- a/default_environment/templates/html/src_block.dust +++ b/default_environment/templates/html/src_block.dust @@ -1,7 +1,6 @@
- -
text
- + {?.language}
{.language}
{/.language} +
{#.lines} diff --git a/src/context/src_block.rs b/src/context/src_block.rs index d5346d7..bc9451a 100644 --- a/src/context/src_block.rs +++ b/src/context/src_block.rs @@ -11,10 +11,12 @@ use super::macros::render; #[serde(rename = "src_block")] pub(crate) struct RenderSrcBlock { lines: Vec, + language: Option, } render!(RenderSrcBlock, ISrcBlock, original, _render_context, { Ok(RenderSrcBlock { lines: original.lines.clone(), + language: original.language.clone(), }) }); diff --git a/src/intermediate/src_block.rs b/src/intermediate/src_block.rs index 0e1b2d1..5ec4520 100644 --- a/src/intermediate/src_block.rs +++ b/src/intermediate/src_block.rs @@ -5,6 +5,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct ISrcBlock { pub(crate) lines: Vec, + pub(crate) language: Option, } intermediate!( @@ -18,6 +19,7 @@ intermediate!( .split_inclusive('\n') .map(|s| s.to_owned()) .collect(); - Ok(ISrcBlock { lines }) + let language = original.language.map(str::to_owned); + Ok(ISrcBlock { lines, language }) } ); From 2ae4839ce0596ddc618c8bee85c3b6a19bc8f382 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 12:27:34 -0500 Subject: [PATCH 08/22] Remove common whitespace prefix from src block lines. --- src/intermediate/src_block.rs | 54 +++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/intermediate/src_block.rs b/src/intermediate/src_block.rs index 5ec4520..145f2ed 100644 --- a/src/intermediate/src_block.rs +++ b/src/intermediate/src_block.rs @@ -14,12 +14,60 @@ intermediate!( original, _registry, { - let lines = original - .get_value() + let source_code = original.get_value(); + let prefix_content_pairs: Vec<_> = source_code .split_inclusive('\n') - .map(|s| s.to_owned()) + .map(|line| { + line.find(|c: char| !c.is_ascii_whitespace() && c != '\n') + .map(|content_start| line.split_at(content_start)) + .map(|(leading_whitespace, content)| { + ( + leading_whitespace + .chars() + .map(ascii_whitespace_value) + .sum::(), + content, + ) + }) + .unwrap_or((0, line)) + }) + .collect(); + let common_whitespace_prefix = prefix_content_pairs + .iter() + .filter_map(|(leading_whitespace, _content)| { + if *leading_whitespace > 0 { + Some(*leading_whitespace) + } else { + None + } + }) + .min() + .unwrap_or(0); + let lines: Vec<_> = prefix_content_pairs + .into_iter() + .map(|(leading_whitespace, content)| { + let mut line = String::with_capacity(common_whitespace_prefix + content.len()); + if leading_whitespace > common_whitespace_prefix { + // Empty lines can have a leading_whitespace less than common_whitespace_prefix. + for _ in 0..(leading_whitespace - common_whitespace_prefix) { + line.push(' '); + } + } + line.push_str(content); + line + }) .collect(); let language = original.language.map(str::to_owned); Ok(ISrcBlock { lines, language }) } ); + +fn ascii_whitespace_value(c: char) -> usize { + match c { + ' ' => 1, + '\t' => 8, + '\r' | '\n' => 0, + c if c as u32 == 12 => 0, // form feed + _ => unreachable!("Only ascii whitespace can reach this code."), + } +} From 8b85c02ef1167f948e4519c2bc9fa54cb2450119 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 13:53:56 -0500 Subject: [PATCH 09/22] Wrap the intermediate Registry in an IntermediateContext. This is currently just to maintain consistency with the render phase's RenderContext but in the future it should allow us to include immutable data that is not locked behind the ArcMutex. --- src/intermediate/ast_node.rs | 251 ++++++++++++----------- src/intermediate/blog_post.rs | 4 +- src/intermediate/bold.rs | 4 +- src/intermediate/code.rs | 2 +- src/intermediate/document_element.rs | 38 ++-- src/intermediate/element.rs | 4 +- src/intermediate/entity.rs | 2 +- src/intermediate/footnote_definition.rs | 9 +- src/intermediate/footnote_reference.rs | 5 +- src/intermediate/heading.rs | 6 +- src/intermediate/inline_source_block.rs | 2 +- src/intermediate/intermediate_context.rs | 15 ++ src/intermediate/italic.rs | 4 +- src/intermediate/latex_fragment.rs | 2 +- src/intermediate/macros.rs | 18 +- src/intermediate/mod.rs | 2 + src/intermediate/object.rs | 4 +- src/intermediate/page.rs | 12 +- src/intermediate/paragraph.rs | 4 +- src/intermediate/plain_list.rs | 4 +- src/intermediate/plain_list_item.rs | 6 +- src/intermediate/plain_text.rs | 2 +- src/intermediate/quote_block.rs | 4 +- src/intermediate/registry.rs | 55 ++--- src/intermediate/regular_link.rs | 4 +- src/intermediate/section.rs | 4 +- src/intermediate/src_block.rs | 2 +- src/intermediate/strike_through.rs | 4 +- src/intermediate/table.rs | 4 +- src/intermediate/table_cell.rs | 4 +- src/intermediate/table_row.rs | 4 +- src/intermediate/target.rs | 4 +- src/intermediate/underline.rs | 4 +- src/intermediate/verbatim.rs | 2 +- 34 files changed, 266 insertions(+), 229 deletions(-) create mode 100644 src/intermediate/intermediate_context.rs diff --git a/src/intermediate/ast_node.rs b/src/intermediate/ast_node.rs index 1288eee..1b3110c 100644 --- a/src/intermediate/ast_node.rs +++ b/src/intermediate/ast_node.rs @@ -18,7 +18,6 @@ use super::plain_link::IPlainLink; use super::plain_text::IPlainText; use super::radio_link::IRadioLink; use super::radio_target::IRadioTarget; - use super::regular_link::IRegularLink; use super::statistics_cookie::IStatisticsCookie; use super::strike_through::IStrikeThrough; @@ -52,7 +51,7 @@ use super::ITimestamp; use super::IUnderline; use super::IVerbatim; use super::IVerseBlock; -use super::RefRegistry; +use super::IntermediateContext; use crate::error::CustomError; use futures::future::{BoxFuture, FutureExt}; @@ -116,23 +115,23 @@ pub(crate) enum IAstNode { pub(crate) trait IntoIAstNode<'parse> { fn into_ast_node<'orig>( &'orig self, - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, ) -> BoxFuture<'orig, Result>; } impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> { fn into_ast_node<'orig>( &'orig self, - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, ) -> BoxFuture<'orig, Result> { async move { match self { - organic::types::DocumentElement::Heading(inner) => { - Ok(IAstNode::Heading(IHeading::new(registry, inner).await?)) - } - organic::types::DocumentElement::Section(inner) => { - Ok(IAstNode::Section(ISection::new(registry, inner).await?)) - } + organic::types::DocumentElement::Heading(inner) => Ok(IAstNode::Heading( + IHeading::new(intermediate_context, inner).await?, + )), + organic::types::DocumentElement::Section(inner) => Ok(IAstNode::Section( + ISection::new(intermediate_context, inner).await?, + )), } } .boxed() @@ -142,81 +141,83 @@ impl<'parse> IntoIAstNode<'parse> for organic::types::DocumentElement<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> { fn into_ast_node<'orig>( &'orig self, - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, ) -> BoxFuture<'orig, Result> { async move { match self { - organic::types::Element::Paragraph(inner) => { - Ok(IAstNode::Paragraph(IParagraph::new(registry, inner).await?)) - } - organic::types::Element::PlainList(inner) => { - Ok(IAstNode::PlainList(IPlainList::new(registry, inner).await?)) - } + organic::types::Element::Paragraph(inner) => Ok(IAstNode::Paragraph( + IParagraph::new(intermediate_context, inner).await?, + )), + organic::types::Element::PlainList(inner) => Ok(IAstNode::PlainList( + IPlainList::new(intermediate_context, inner).await?, + )), organic::types::Element::CenterBlock(inner) => Ok(IAstNode::CenterBlock( - ICenterBlock::new(registry, inner).await?, + ICenterBlock::new(intermediate_context, inner).await?, )), organic::types::Element::QuoteBlock(inner) => Ok(IAstNode::QuoteBlock( - IQuoteBlock::new(registry, inner).await?, + IQuoteBlock::new(intermediate_context, inner).await?, )), organic::types::Element::SpecialBlock(inner) => Ok(IAstNode::SpecialBlock( - ISpecialBlock::new(registry, inner).await?, + ISpecialBlock::new(intermediate_context, inner).await?, )), organic::types::Element::DynamicBlock(inner) => Ok(IAstNode::DynamicBlock( - IDynamicBlock::new(registry, inner).await?, + IDynamicBlock::new(intermediate_context, inner).await?, )), - organic::types::Element::FootnoteDefinition(inner) => Ok( - IAstNode::FootnoteDefinition(IFootnoteDefinition::new(registry, inner).await?), - ), - organic::types::Element::Comment(inner) => { - Ok(IAstNode::Comment(IComment::new(registry, inner).await?)) - } - organic::types::Element::Drawer(inner) => { - Ok(IAstNode::Drawer(IDrawer::new(registry, inner).await?)) + organic::types::Element::FootnoteDefinition(inner) => { + Ok(IAstNode::FootnoteDefinition( + IFootnoteDefinition::new(intermediate_context, inner).await?, + )) } + organic::types::Element::Comment(inner) => Ok(IAstNode::Comment( + IComment::new(intermediate_context, inner).await?, + )), + organic::types::Element::Drawer(inner) => Ok(IAstNode::Drawer( + IDrawer::new(intermediate_context, inner).await?, + )), organic::types::Element::PropertyDrawer(inner) => Ok(IAstNode::PropertyDrawer( - IPropertyDrawer::new(registry, inner).await?, + IPropertyDrawer::new(intermediate_context, inner).await?, + )), + organic::types::Element::Table(inner) => Ok(IAstNode::Table( + ITable::new(intermediate_context, inner).await?, )), - organic::types::Element::Table(inner) => { - Ok(IAstNode::Table(ITable::new(registry, inner).await?)) - } organic::types::Element::VerseBlock(inner) => Ok(IAstNode::VerseBlock( - IVerseBlock::new(registry, inner).await?, + IVerseBlock::new(intermediate_context, inner).await?, )), organic::types::Element::CommentBlock(inner) => Ok(IAstNode::CommentBlock( - ICommentBlock::new(registry, inner).await?, + ICommentBlock::new(intermediate_context, inner).await?, )), organic::types::Element::ExampleBlock(inner) => Ok(IAstNode::ExampleBlock( - IExampleBlock::new(registry, inner).await?, + IExampleBlock::new(intermediate_context, inner).await?, )), organic::types::Element::ExportBlock(inner) => Ok(IAstNode::ExportBlock( - IExportBlock::new(registry, inner).await?, + IExportBlock::new(intermediate_context, inner).await?, + )), + organic::types::Element::SrcBlock(inner) => Ok(IAstNode::SrcBlock( + ISrcBlock::new(intermediate_context, inner).await?, + )), + organic::types::Element::Clock(inner) => Ok(IAstNode::Clock( + IClock::new(intermediate_context, inner).await?, + )), + organic::types::Element::DiarySexp(inner) => Ok(IAstNode::DiarySexp( + IDiarySexp::new(intermediate_context, inner).await?, + )), + organic::types::Element::Planning(inner) => Ok(IAstNode::Planning( + IPlanning::new(intermediate_context, inner).await?, )), - organic::types::Element::SrcBlock(inner) => { - Ok(IAstNode::SrcBlock(ISrcBlock::new(registry, inner).await?)) - } - organic::types::Element::Clock(inner) => { - Ok(IAstNode::Clock(IClock::new(registry, inner).await?)) - } - organic::types::Element::DiarySexp(inner) => { - Ok(IAstNode::DiarySexp(IDiarySexp::new(registry, inner).await?)) - } - organic::types::Element::Planning(inner) => { - Ok(IAstNode::Planning(IPlanning::new(registry, inner).await?)) - } organic::types::Element::FixedWidthArea(inner) => Ok(IAstNode::FixedWidthArea( - IFixedWidthArea::new(registry, inner).await?, + IFixedWidthArea::new(intermediate_context, inner).await?, )), organic::types::Element::HorizontalRule(inner) => Ok(IAstNode::HorizontalRule( - IHorizontalRule::new(registry, inner).await?, + IHorizontalRule::new(intermediate_context, inner).await?, + )), + organic::types::Element::Keyword(inner) => Ok(IAstNode::Keyword( + IKeyword::new(intermediate_context, inner).await?, + )), + organic::types::Element::BabelCall(inner) => Ok(IAstNode::BabelCall( + IBabelCall::new(intermediate_context, inner).await?, )), - organic::types::Element::Keyword(inner) => { - Ok(IAstNode::Keyword(IKeyword::new(registry, inner).await?)) - } - organic::types::Element::BabelCall(inner) => { - Ok(IAstNode::BabelCall(IBabelCall::new(registry, inner).await?)) - } organic::types::Element::LatexEnvironment(inner) => Ok(IAstNode::LatexEnvironment( - ILatexEnvironment::new(registry, inner).await?, + ILatexEnvironment::new(intermediate_context, inner).await?, )), } } @@ -227,91 +228,97 @@ impl<'parse> IntoIAstNode<'parse> for organic::types::Element<'parse> { impl<'parse> IntoIAstNode<'parse> for organic::types::Object<'parse> { fn into_ast_node<'orig>( &'orig self, - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, ) -> BoxFuture<'orig, Result> { async move { match self { - organic::types::Object::Bold(inner) => { - Ok(IAstNode::Bold(IBold::new(registry, inner).await?)) - } - organic::types::Object::Italic(inner) => { - Ok(IAstNode::Italic(IItalic::new(registry, inner).await?)) - } - organic::types::Object::Underline(inner) => { - Ok(IAstNode::Underline(IUnderline::new(registry, inner).await?)) - } + organic::types::Object::Bold(inner) => Ok(IAstNode::Bold( + IBold::new(intermediate_context, inner).await?, + )), + organic::types::Object::Italic(inner) => Ok(IAstNode::Italic( + IItalic::new(intermediate_context, inner).await?, + )), + organic::types::Object::Underline(inner) => Ok(IAstNode::Underline( + IUnderline::new(intermediate_context, inner).await?, + )), organic::types::Object::StrikeThrough(inner) => Ok(IAstNode::StrikeThrough( - IStrikeThrough::new(registry, inner).await?, + IStrikeThrough::new(intermediate_context, inner).await?, + )), + organic::types::Object::Code(inner) => Ok(IAstNode::Code( + ICode::new(intermediate_context, inner).await?, + )), + organic::types::Object::Verbatim(inner) => Ok(IAstNode::Verbatim( + IVerbatim::new(intermediate_context, inner).await?, + )), + organic::types::Object::PlainText(inner) => Ok(IAstNode::PlainText( + IPlainText::new(intermediate_context, inner).await?, )), - organic::types::Object::Code(inner) => { - Ok(IAstNode::Code(ICode::new(registry, inner).await?)) - } - organic::types::Object::Verbatim(inner) => { - Ok(IAstNode::Verbatim(IVerbatim::new(registry, inner).await?)) - } - organic::types::Object::PlainText(inner) => { - Ok(IAstNode::PlainText(IPlainText::new(registry, inner).await?)) - } organic::types::Object::RegularLink(inner) => Ok(IAstNode::RegularLink( - IRegularLink::new(registry, inner).await?, + IRegularLink::new(intermediate_context, inner).await?, + )), + organic::types::Object::RadioLink(inner) => Ok(IAstNode::RadioLink( + IRadioLink::new(intermediate_context, inner).await?, )), - organic::types::Object::RadioLink(inner) => { - Ok(IAstNode::RadioLink(IRadioLink::new(registry, inner).await?)) - } organic::types::Object::RadioTarget(inner) => Ok(IAstNode::RadioTarget( - IRadioTarget::new(registry, inner).await?, + IRadioTarget::new(intermediate_context, inner).await?, + )), + organic::types::Object::PlainLink(inner) => Ok(IAstNode::PlainLink( + IPlainLink::new(intermediate_context, inner).await?, + )), + organic::types::Object::AngleLink(inner) => Ok(IAstNode::AngleLink( + IAngleLink::new(intermediate_context, inner).await?, + )), + organic::types::Object::OrgMacro(inner) => Ok(IAstNode::OrgMacro( + IOrgMacro::new(intermediate_context, inner).await?, + )), + organic::types::Object::Entity(inner) => Ok(IAstNode::Entity( + IEntity::new(intermediate_context, inner).await?, )), - organic::types::Object::PlainLink(inner) => { - Ok(IAstNode::PlainLink(IPlainLink::new(registry, inner).await?)) - } - organic::types::Object::AngleLink(inner) => { - Ok(IAstNode::AngleLink(IAngleLink::new(registry, inner).await?)) - } - organic::types::Object::OrgMacro(inner) => { - Ok(IAstNode::OrgMacro(IOrgMacro::new(registry, inner).await?)) - } - organic::types::Object::Entity(inner) => { - Ok(IAstNode::Entity(IEntity::new(registry, inner).await?)) - } organic::types::Object::LatexFragment(inner) => Ok(IAstNode::LatexFragment( - ILatexFragment::new(registry, inner).await?, + ILatexFragment::new(intermediate_context, inner).await?, )), organic::types::Object::ExportSnippet(inner) => Ok(IAstNode::ExportSnippet( - IExportSnippet::new(registry, inner).await?, + IExportSnippet::new(intermediate_context, inner).await?, )), - organic::types::Object::FootnoteReference(inner) => Ok( - IAstNode::FootnoteReference(IFootnoteReference::new(registry, inner).await?), - ), - organic::types::Object::Citation(inner) => { - Ok(IAstNode::Citation(ICitation::new(registry, inner).await?)) + organic::types::Object::FootnoteReference(inner) => { + Ok(IAstNode::FootnoteReference( + IFootnoteReference::new(intermediate_context, inner).await?, + )) + } + organic::types::Object::Citation(inner) => Ok(IAstNode::Citation( + ICitation::new(intermediate_context, inner).await?, + )), + organic::types::Object::CitationReference(inner) => { + Ok(IAstNode::CitationReference( + ICitationReference::new(intermediate_context, inner).await?, + )) } - organic::types::Object::CitationReference(inner) => Ok( - IAstNode::CitationReference(ICitationReference::new(registry, inner).await?), - ), organic::types::Object::InlineBabelCall(inner) => Ok(IAstNode::InlineBabelCall( - IInlineBabelCall::new(registry, inner).await?, + IInlineBabelCall::new(intermediate_context, inner).await?, )), - organic::types::Object::InlineSourceBlock(inner) => Ok( - IAstNode::InlineSourceBlock(IInlineSourceBlock::new(registry, inner).await?), - ), - organic::types::Object::LineBreak(inner) => { - Ok(IAstNode::LineBreak(ILineBreak::new(registry, inner).await?)) - } - organic::types::Object::Target(inner) => { - Ok(IAstNode::Target(ITarget::new(registry, inner).await?)) + organic::types::Object::InlineSourceBlock(inner) => { + Ok(IAstNode::InlineSourceBlock( + IInlineSourceBlock::new(intermediate_context, inner).await?, + )) } + organic::types::Object::LineBreak(inner) => Ok(IAstNode::LineBreak( + ILineBreak::new(intermediate_context, inner).await?, + )), + organic::types::Object::Target(inner) => Ok(IAstNode::Target( + ITarget::new(intermediate_context, inner).await?, + )), organic::types::Object::StatisticsCookie(inner) => Ok(IAstNode::StatisticsCookie( - IStatisticsCookie::new(registry, inner).await?, + IStatisticsCookie::new(intermediate_context, inner).await?, + )), + organic::types::Object::Subscript(inner) => Ok(IAstNode::Subscript( + ISubscript::new(intermediate_context, inner).await?, )), - organic::types::Object::Subscript(inner) => { - Ok(IAstNode::Subscript(ISubscript::new(registry, inner).await?)) - } organic::types::Object::Superscript(inner) => Ok(IAstNode::Superscript( - ISuperscript::new(registry, inner).await?, + ISuperscript::new(intermediate_context, inner).await?, + )), + organic::types::Object::Timestamp(inner) => Ok(IAstNode::Timestamp( + ITimestamp::new(intermediate_context, inner).await?, )), - organic::types::Object::Timestamp(inner) => { - Ok(IAstNode::Timestamp(ITimestamp::new(registry, inner).await?)) - } } } .boxed() diff --git a/src/intermediate/blog_post.rs b/src/intermediate/blog_post.rs index 6116653..ad74e79 100644 --- a/src/intermediate/blog_post.rs +++ b/src/intermediate/blog_post.rs @@ -9,6 +9,7 @@ use walkdir::WalkDir; use crate::error::CustomError; use crate::intermediate::page::BlogPostPageInput; use crate::intermediate::registry::Registry; +use crate::intermediate::IntermediateContext; use super::BlogPostPage; @@ -62,10 +63,11 @@ impl BlogPost { }); let registry = Arc::new(Mutex::new(registry)); + let intermediate_context = IntermediateContext::new(registry)?; let relative_to_post_dir_path = real_path.strip_prefix(post_dir)?; ret.push( BlogPostPage::new( - registry, + intermediate_context, BlogPostPageInput::new(relative_to_post_dir_path, parsed_document), ) .await?, diff --git a/src/intermediate/bold.rs b/src/intermediate/bold.rs index 6774fb0..7d7e751 100644 --- a/src/intermediate/bold.rs +++ b/src/intermediate/bold.rs @@ -12,12 +12,12 @@ intermediate!( IBold, &'orig organic::types::Bold<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/code.rs b/src/intermediate/code.rs index 6f32ac6..d166683 100644 --- a/src/intermediate/code.rs +++ b/src/intermediate/code.rs @@ -11,7 +11,7 @@ intermediate!( ICode, &'orig organic::types::Code<'parse>, original, - _registry, + _intermediate_context, { Ok(ICode { // TODO: Should this coalesce whitespace like PlainText? diff --git a/src/intermediate/document_element.rs b/src/intermediate/document_element.rs index d8ee0f5..57356bc 100644 --- a/src/intermediate/document_element.rs +++ b/src/intermediate/document_element.rs @@ -12,19 +12,25 @@ pub(crate) enum IDocumentElement { Section(ISection), } -iselector!(IDocumentElement, DocumentElement, original, registry, { - iitem!( - registry, - original, - ( - organic::types::DocumentElement::Heading, - IDocumentElement::Heading, - IHeading - ), - ( - organic::types::DocumentElement::Section, - IDocumentElement::Section, - ISection - ), - ) -}); +iselector!( + IDocumentElement, + DocumentElement, + original, + intermediate_context, + { + iitem!( + intermediate_context, + original, + ( + organic::types::DocumentElement::Heading, + IDocumentElement::Heading, + IHeading + ), + ( + organic::types::DocumentElement::Section, + IDocumentElement::Section, + ISection + ), + ) + } +); diff --git a/src/intermediate/element.rs b/src/intermediate/element.rs index 4769986..5072ea4 100644 --- a/src/intermediate/element.rs +++ b/src/intermediate/element.rs @@ -56,9 +56,9 @@ pub(crate) enum IElement { LatexEnvironment(ILatexEnvironment), } -iselector!(IElement, Element, original, registry, { +iselector!(IElement, Element, original, intermediate_context, { iitem!( - registry, + intermediate_context, original, ( organic::types::Element::Paragraph, diff --git a/src/intermediate/entity.rs b/src/intermediate/entity.rs index 071daa0..11dff6d 100644 --- a/src/intermediate/entity.rs +++ b/src/intermediate/entity.rs @@ -11,7 +11,7 @@ intermediate!( IEntity, &'orig organic::types::Entity<'parse>, original, - _registry, + _intermediate_context, { Ok(IEntity { html: original.html.to_owned(), diff --git a/src/intermediate/footnote_definition.rs b/src/intermediate/footnote_definition.rs index 265c215..bef6779 100644 --- a/src/intermediate/footnote_definition.rs +++ b/src/intermediate/footnote_definition.rs @@ -1,9 +1,9 @@ use super::macros::intermediate; use super::registry::register_footnote_definition; +use super::IntermediateContext; use super::IAstNode; use crate::error::CustomError; -use crate::intermediate::RefRegistry; #[derive(Debug, Clone)] pub(crate) struct IFootnoteDefinition {} @@ -12,9 +12,10 @@ intermediate!( IFootnoteDefinition, &'orig organic::types::FootnoteDefinition<'parse>, original, - registry, + intermediate_context, { - register_footnote_definition(registry, original.label, &original.children).await?; + register_footnote_definition(intermediate_context, original.label, &original.children) + .await?; Ok(IFootnoteDefinition {}) } ); @@ -27,7 +28,7 @@ pub(crate) struct IRealFootnoteDefinition { impl IRealFootnoteDefinition { pub(crate) async fn new<'orig, 'parse>( - _registry: RefRegistry<'orig, 'parse>, + _intermediate_context: IntermediateContext<'orig, 'parse>, footnote_id: usize, contents: Vec, ) -> Result { diff --git a/src/intermediate/footnote_reference.rs b/src/intermediate/footnote_reference.rs index 175edd2..5aef79d 100644 --- a/src/intermediate/footnote_reference.rs +++ b/src/intermediate/footnote_reference.rs @@ -13,10 +13,11 @@ intermediate!( IFootnoteReference, &'orig organic::types::FootnoteReference<'parse>, original, - registry, + intermediate_context, { let (footnote_id, reference_count) = - get_footnote_reference_id(registry, original.label, &original.definition).await?; + get_footnote_reference_id(intermediate_context, original.label, &original.definition) + .await?; Ok(IFootnoteReference { footnote_id, duplicate_offset: reference_count, diff --git a/src/intermediate/heading.rs b/src/intermediate/heading.rs index 74830b3..fbaba46 100644 --- a/src/intermediate/heading.rs +++ b/src/intermediate/heading.rs @@ -15,19 +15,19 @@ intermediate!( IHeading, &'orig organic::types::Heading<'parse>, original, - registry, + intermediate_context, { let title = { let mut ret = Vec::new(); for obj in original.title.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IDocumentElement::new(registry.clone(), obj).await?); + ret.push(IDocumentElement::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/inline_source_block.rs b/src/intermediate/inline_source_block.rs index 68e31b2..ab32a9c 100644 --- a/src/intermediate/inline_source_block.rs +++ b/src/intermediate/inline_source_block.rs @@ -11,7 +11,7 @@ intermediate!( IInlineSourceBlock, &'orig organic::types::InlineSourceBlock<'parse>, original, - _registry, + _intermediate_context, { Ok(IInlineSourceBlock { value: original.value.to_owned(), diff --git a/src/intermediate/intermediate_context.rs b/src/intermediate/intermediate_context.rs new file mode 100644 index 0000000..ca369a2 --- /dev/null +++ b/src/intermediate/intermediate_context.rs @@ -0,0 +1,15 @@ +use crate::error::CustomError; + +/// The supporting information used for converting the parsed org source representation into the intermediate representation used in this project. +#[derive(Debug, Clone)] +pub(crate) struct IntermediateContext<'orig, 'parse> { + pub(crate) registry: crate::intermediate::RefRegistry<'orig, 'parse>, +} + +impl<'orig, 'parse> IntermediateContext<'orig, 'parse> { + pub(crate) fn new( + registry: crate::intermediate::RefRegistry<'orig, 'parse>, + ) -> Result, CustomError> { + Ok(IntermediateContext { registry }) + } +} diff --git a/src/intermediate/italic.rs b/src/intermediate/italic.rs index 23ecdc3..44bb165 100644 --- a/src/intermediate/italic.rs +++ b/src/intermediate/italic.rs @@ -12,12 +12,12 @@ intermediate!( IItalic, &'orig organic::types::Italic<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/latex_fragment.rs b/src/intermediate/latex_fragment.rs index 75cf59e..ee4195d 100644 --- a/src/intermediate/latex_fragment.rs +++ b/src/intermediate/latex_fragment.rs @@ -11,7 +11,7 @@ intermediate!( ILatexFragment, &'orig organic::types::LatexFragment<'parse>, original, - _registry, + _intermediate_context, { let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") { format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)]) diff --git a/src/intermediate/macros.rs b/src/intermediate/macros.rs index b3c5465..8b9623f 100644 --- a/src/intermediate/macros.rs +++ b/src/intermediate/macros.rs @@ -8,7 +8,7 @@ macro_rules! inoop { impl $istruct { pub(crate) async fn new<'reg, 'orig, 'parse>( - _registry: crate::intermediate::RefRegistry<'orig, 'parse>, + _intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, _original: &'orig organic::types::$pstruct<'parse>, ) -> Result<$istruct, CustomError> { Ok($istruct {}) @@ -23,10 +23,10 @@ pub(crate) use inoop; /// /// This exists to make changing the type signature easier. macro_rules! intermediate { - ($istruct:ident, $pstruct:ty, $original:ident, $registry:ident, $fnbody:tt) => { + ($istruct:ident, $pstruct:ty, $original:ident, $intermediate_context:ident, $fnbody:tt) => { impl $istruct { pub(crate) async fn new<'orig, 'parse>( - $registry: crate::intermediate::RefRegistry<'orig, 'parse>, + $intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, $original: $pstruct, ) -> Result<$istruct, CustomError> { $fnbody @@ -41,14 +41,12 @@ pub(crate) use intermediate; /// /// This exists to make changing the type signature easier. macro_rules! iselector { - ($istruct:ident, $pstruct:ident, $original:ident, $registry:ident, $fnbody:tt) => { + ($istruct:ident, $pstruct:ident, $original:ident, $intermediate_context:ident, $fnbody:tt) => { impl $istruct { pub(crate) fn new<'orig, 'parse>( - registry: crate::intermediate::RefRegistry<'orig, 'parse>, - original: &'orig organic::types::$pstruct<'parse>, + $intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, + $original: &'orig organic::types::$pstruct<'parse>, ) -> BoxFuture<'orig, Result<$istruct, CustomError>> { - let $registry = registry; - let $original = original; async move { $fnbody }.boxed() } } @@ -58,11 +56,11 @@ macro_rules! iselector { pub(crate) use iselector; macro_rules! iitem { - ($registry:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => { + ($intermediate_context:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => { match $original { $( $penum(inner) => Ok($ienum( - $istruct::new($registry.clone(), inner).await?, + $istruct::new($intermediate_context.clone(), inner).await?, )), )* } diff --git a/src/intermediate/mod.rs b/src/intermediate/mod.rs index 4a7595f..ea61ba1 100644 --- a/src/intermediate/mod.rs +++ b/src/intermediate/mod.rs @@ -27,6 +27,7 @@ mod heading; mod horizontal_rule; mod inline_babel_call; mod inline_source_block; +mod intermediate_context; mod italic; mod keyword; mod latex_environment; @@ -94,6 +95,7 @@ pub(crate) use heading::IHeading; pub(crate) use horizontal_rule::IHorizontalRule; pub(crate) use inline_babel_call::IInlineBabelCall; pub(crate) use inline_source_block::IInlineSourceBlock; +pub(crate) use intermediate_context::IntermediateContext; pub(crate) use italic::IItalic; pub(crate) use keyword::IKeyword; pub(crate) use latex_environment::ILatexEnvironment; diff --git a/src/intermediate/object.rs b/src/intermediate/object.rs index 533651f..651ac99 100644 --- a/src/intermediate/object.rs +++ b/src/intermediate/object.rs @@ -63,9 +63,9 @@ pub(crate) enum IObject { Timestamp(ITimestamp), } -iselector!(IObject, Object, original, registry, { +iselector!(IObject, Object, original, intermediate_context, { iitem!( - registry, + intermediate_context, original, (organic::types::Object::Bold, IObject::Bold, IBold), (organic::types::Object::Italic, IObject::Italic, IItalic), diff --git a/src/intermediate/page.rs b/src/intermediate/page.rs index 8de8e24..bc0603d 100644 --- a/src/intermediate/page.rs +++ b/src/intermediate/page.rs @@ -45,23 +45,23 @@ intermediate!( BlogPostPage, BlogPostPageInput<'orig, 'parse>, original, - registry, + intermediate_context, { let mut children = Vec::new(); if let Some(section) = original.document.zeroth_section.as_ref() { children.push(IDocumentElement::Section( - ISection::new(registry.clone(), section).await?, + ISection::new(intermediate_context.clone(), section).await?, )); } for heading in original.document.children.iter() { children.push(IDocumentElement::Heading( - IHeading::new(registry.clone(), heading).await?, + IHeading::new(intermediate_context.clone(), heading).await?, )); } let footnotes = { let footnote_definitions: Vec<_> = { - let registry = registry.lock().unwrap(); + let registry = intermediate_context.registry.lock().unwrap(); let ret = registry .get_footnote_ids() .map(|(id, def)| (id, def.clone())) @@ -70,7 +70,9 @@ intermediate!( }; let mut ret = Vec::new(); for (id, def) in footnote_definitions.into_iter() { - ret.push(IRealFootnoteDefinition::new(registry.clone(), id, def).await?); + ret.push( + IRealFootnoteDefinition::new(intermediate_context.clone(), id, def).await?, + ); } ret }; diff --git a/src/intermediate/paragraph.rs b/src/intermediate/paragraph.rs index 2c2e112..a93eb57 100644 --- a/src/intermediate/paragraph.rs +++ b/src/intermediate/paragraph.rs @@ -12,12 +12,12 @@ intermediate!( IParagraph, &'orig organic::types::Paragraph<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/plain_list.rs b/src/intermediate/plain_list.rs index 68dc0b8..063305e 100644 --- a/src/intermediate/plain_list.rs +++ b/src/intermediate/plain_list.rs @@ -13,12 +13,12 @@ intermediate!( IPlainList, &'orig organic::types::PlainList<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IPlainListItem::new(registry.clone(), obj).await?); + ret.push(IPlainListItem::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/plain_list_item.rs b/src/intermediate/plain_list_item.rs index ca971c6..02f3241 100644 --- a/src/intermediate/plain_list_item.rs +++ b/src/intermediate/plain_list_item.rs @@ -14,12 +14,12 @@ intermediate!( IPlainListItem, &'orig organic::types::PlainListItem<'parse>, original, - registry, + intermediate_context, { let tag = { let mut ret = Vec::new(); for obj in original.tag.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; @@ -27,7 +27,7 @@ intermediate!( let children = { let mut ret = Vec::new(); for elem in original.children.iter() { - ret.push(IElement::new(registry.clone(), elem).await?); + ret.push(IElement::new(intermediate_context.clone(), elem).await?); } ret }; diff --git a/src/intermediate/plain_text.rs b/src/intermediate/plain_text.rs index ee419ad..a346cbe 100644 --- a/src/intermediate/plain_text.rs +++ b/src/intermediate/plain_text.rs @@ -12,7 +12,7 @@ intermediate!( IPlainText, &'orig organic::types::PlainText<'parse>, original, - _registry, + _intermediate_context, { Ok(IPlainText { source: coalesce_whitespace(original.source).into_owned(), diff --git a/src/intermediate/quote_block.rs b/src/intermediate/quote_block.rs index e7485d0..68daeda 100644 --- a/src/intermediate/quote_block.rs +++ b/src/intermediate/quote_block.rs @@ -12,12 +12,12 @@ intermediate!( IQuoteBlock, &'orig organic::types::QuoteBlock<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IElement::new(registry.clone(), obj).await?); + ret.push(IElement::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/registry.rs b/src/intermediate/registry.rs index 3ae276e..64d1800 100644 --- a/src/intermediate/registry.rs +++ b/src/intermediate/registry.rs @@ -5,10 +5,11 @@ use std::collections::HashMap; use super::ast_node::IAstNode; use super::ast_node::IntoIAstNode; -use super::RefRegistry; +use super::IntermediateContext; type IdCounter = u16; +#[derive(Debug)] pub(crate) struct Registry<'orig, 'parse> { id_counter: IdCounter, targets: HashMap<&'parse str, String>, @@ -47,15 +48,15 @@ impl<'orig, 'parse> Registry<'orig, 'parse> { /// /// This needs to be incremented to be 1-indexed for render. pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, label: Option<&'parse str>, definition: &'orig Vec>, ) -> Result<(usize, usize), CustomError> { if let None = label { // If it has no label then it must always get a new ID. - let contents = convert_reference_contents(registry.clone(), definition).await?; + let contents = convert_reference_contents(intermediate_context.clone(), definition).await?; let pos = { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); registry.footnote_ids.push((None, contents)); registry.footnote_ids.len() - 1 }; @@ -63,8 +64,8 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( } let reference_count = if let Some(label) = label { - promote_footnote_definition(registry.clone(), label).await?; - let mut registry = registry.lock().unwrap(); + promote_footnote_definition(intermediate_context.clone(), label).await?; + let mut registry = intermediate_context.registry.lock().unwrap(); let reference_count = registry .footnote_reference_counts .entry(label) @@ -75,7 +76,8 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( 0 }; - let existing_index = registry + let existing_index = intermediate_context + .registry .lock() .unwrap() .footnote_ids @@ -83,8 +85,9 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( .position(|(id, _definition)| *id == label); if let Some(existing_id) = existing_index { if !definition.is_empty() { - let contents = convert_reference_contents(registry.clone(), definition).await?; - let mut registry = registry.lock().unwrap(); + let contents = + convert_reference_contents(intermediate_context.clone(), definition).await?; + let mut registry = intermediate_context.registry.lock().unwrap(); let entry = registry .footnote_ids .get_mut(existing_id) @@ -94,13 +97,13 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( Ok((existing_id, reference_count)) } else { let existing_id = { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); registry.footnote_ids.push((label, Vec::new())); registry.footnote_ids.len() - 1 }; - let contents = convert_reference_contents(registry.clone(), definition).await?; + let contents = convert_reference_contents(intermediate_context.clone(), definition).await?; { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); let entry = registry .footnote_ids .get_mut(existing_id) @@ -113,24 +116,24 @@ pub(crate) async fn get_footnote_reference_id<'orig, 'parse>( /// Update the definition to a footnote but do not mark it as referenced. pub(crate) async fn register_footnote_definition<'orig, 'parse>( - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, label: &'parse str, definition: &'orig Vec>, ) -> Result<(), CustomError> { let has_existing: bool = { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); registry .footnote_ids .iter_mut() .any(|(id, _definition)| *id == Some(label)) }; if !has_existing { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); registry.on_deck_footnote_ids.insert(label, definition); return Ok(()); } - let contents = convert_definition_contents(registry.clone(), definition).await?; - let mut registry = registry.lock().unwrap(); + let contents = convert_definition_contents(intermediate_context.clone(), definition).await?; + let mut registry = intermediate_context.registry.lock().unwrap(); if let Some((_existing_id, existing_definition)) = registry .footnote_ids .iter_mut() @@ -142,13 +145,13 @@ pub(crate) async fn register_footnote_definition<'orig, 'parse>( } async fn convert_reference_contents<'orig, 'parse>( - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, contents: &'orig Vec>, ) -> Result, CustomError> { let contents = { let mut ret = Vec::new(); for obj in contents.iter() { - ret.push(obj.into_ast_node(registry.clone()).await?); + ret.push(obj.into_ast_node(intermediate_context.clone()).await?); } ret }; @@ -157,13 +160,13 @@ async fn convert_reference_contents<'orig, 'parse>( } async fn convert_definition_contents<'orig, 'parse>( - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, contents: &'orig Vec>, ) -> Result, CustomError> { let contents = { let mut ret = Vec::new(); for obj in contents.iter() { - ret.push(obj.into_ast_node(registry.clone()).await?); + ret.push(obj.into_ast_node(intermediate_context.clone()).await?); } ret }; @@ -173,23 +176,23 @@ async fn convert_definition_contents<'orig, 'parse>( /// Take a footnote definition that has not yet received a reference and move it into the active footnotes. pub(crate) async fn promote_footnote_definition<'orig, 'parse>( - registry: RefRegistry<'orig, 'parse>, + intermediate_context: IntermediateContext<'orig, 'parse>, label: &'parse str, ) -> Result<(), CustomError> { let definition = { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); let definition = registry.on_deck_footnote_ids.remove(label); definition }; if let Some(elements) = definition { let existing_id = { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); registry.footnote_ids.push((Some(label), Vec::new())); registry.footnote_ids.len() - 1 }; - let contents = convert_definition_contents(registry.clone(), elements).await?; + let contents = convert_definition_contents(intermediate_context.clone(), elements).await?; { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); let entry = registry .footnote_ids .get_mut(existing_id) diff --git a/src/intermediate/regular_link.rs b/src/intermediate/regular_link.rs index 5f10fb0..14262ee 100644 --- a/src/intermediate/regular_link.rs +++ b/src/intermediate/regular_link.rs @@ -13,12 +13,12 @@ intermediate!( IRegularLink, &'orig organic::types::RegularLink<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/section.rs b/src/intermediate/section.rs index 9dc1119..defca30 100644 --- a/src/intermediate/section.rs +++ b/src/intermediate/section.rs @@ -12,12 +12,12 @@ intermediate!( ISection, &'orig organic::types::Section<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for elem in original.children.iter() { - ret.push(IElement::new(registry.clone(), elem).await?); + ret.push(IElement::new(intermediate_context.clone(), elem).await?); } ret }; diff --git a/src/intermediate/src_block.rs b/src/intermediate/src_block.rs index 145f2ed..6bc9ef0 100644 --- a/src/intermediate/src_block.rs +++ b/src/intermediate/src_block.rs @@ -12,7 +12,7 @@ intermediate!( ISrcBlock, &'orig organic::types::SrcBlock<'parse>, original, - _registry, + _intermediate_context, { let source_code = original.get_value(); let prefix_content_pairs: Vec<_> = source_code diff --git a/src/intermediate/strike_through.rs b/src/intermediate/strike_through.rs index 40d0fb5..151a4ee 100644 --- a/src/intermediate/strike_through.rs +++ b/src/intermediate/strike_through.rs @@ -12,12 +12,12 @@ intermediate!( IStrikeThrough, &'orig organic::types::StrikeThrough<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/table.rs b/src/intermediate/table.rs index 396d05b..cc99add 100644 --- a/src/intermediate/table.rs +++ b/src/intermediate/table.rs @@ -12,12 +12,12 @@ intermediate!( ITable, &'orig organic::types::Table<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(ITableRow::new(registry.clone(), obj).await?); + ret.push(ITableRow::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/table_cell.rs b/src/intermediate/table_cell.rs index 37691c4..deca27d 100644 --- a/src/intermediate/table_cell.rs +++ b/src/intermediate/table_cell.rs @@ -12,12 +12,12 @@ intermediate!( ITableCell, &'orig organic::types::TableCell<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/table_row.rs b/src/intermediate/table_row.rs index 666519d..2faa9e4 100644 --- a/src/intermediate/table_row.rs +++ b/src/intermediate/table_row.rs @@ -11,12 +11,12 @@ intermediate!( ITableRow, &'orig organic::types::TableRow<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(ITableCell::new(registry.clone(), obj).await?); + ret.push(ITableCell::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/target.rs b/src/intermediate/target.rs index de3b32e..3030fe9 100644 --- a/src/intermediate/target.rs +++ b/src/intermediate/target.rs @@ -12,9 +12,9 @@ intermediate!( ITarget, &'orig organic::types::Target<'parse>, original, - registry, + intermediate_context, { - let mut registry = registry.lock().unwrap(); + let mut registry = intermediate_context.registry.lock().unwrap(); let id = registry.get_target(original.value); Ok(ITarget { id: id.clone(), diff --git a/src/intermediate/underline.rs b/src/intermediate/underline.rs index 1fd1b3c..ebbde2f 100644 --- a/src/intermediate/underline.rs +++ b/src/intermediate/underline.rs @@ -12,12 +12,12 @@ intermediate!( IUnderline, &'orig organic::types::Underline<'parse>, original, - registry, + intermediate_context, { let children = { let mut ret = Vec::new(); for obj in original.children.iter() { - ret.push(IObject::new(registry.clone(), obj).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; diff --git a/src/intermediate/verbatim.rs b/src/intermediate/verbatim.rs index 6e83727..787c244 100644 --- a/src/intermediate/verbatim.rs +++ b/src/intermediate/verbatim.rs @@ -11,7 +11,7 @@ intermediate!( IVerbatim, &'orig organic::types::Verbatim<'parse>, original, - _registry, + _intermediate_context, { Ok(IVerbatim { // TODO: Should this coalesce whitespace like PlainText? From 72952adb6b47890bf32107d984a0d92ecc21936a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 14:56:58 -0500 Subject: [PATCH 10/22] Add post_blank to the rust types. --- src/context/angle_link.rs | 4 +++- src/context/babel_call.rs | 4 +++- src/context/bold.rs | 6 +++++- src/context/center_block.rs | 4 +++- src/context/citation.rs | 4 +++- src/context/citation_reference.rs | 4 +++- src/context/clock.rs | 4 +++- src/context/code.rs | 2 ++ src/context/comment.rs | 4 +++- src/context/comment_block.rs | 4 +++- src/context/diary_sexp.rs | 4 +++- src/context/drawer.rs | 4 +++- src/context/dynamic_block.rs | 4 +++- src/context/entity.rs | 2 ++ src/context/example_block.rs | 4 +++- src/context/export_block.rs | 4 +++- src/context/export_snippet.rs | 4 +++- src/context/fixed_width_area.rs | 4 +++- src/context/footnote_definition.rs | 7 +++++-- src/context/footnote_reference.rs | 2 ++ src/context/heading.rs | 2 ++ src/context/horizontal_rule.rs | 4 +++- src/context/inline_babel_call.rs | 4 +++- src/context/inline_source_block.rs | 2 ++ src/context/italic.rs | 6 +++++- src/context/keyword.rs | 4 +++- src/context/latex_environment.rs | 4 +++- src/context/latex_fragment.rs | 2 ++ src/context/line_break.rs | 4 +++- src/context/macros.rs | 6 ++++-- src/context/org_macro.rs | 4 +++- src/context/paragraph.rs | 6 +++++- src/context/plain_link.rs | 4 +++- src/context/plain_list.rs | 2 ++ src/context/plain_text.rs | 2 ++ src/context/planning.rs | 4 +++- src/context/property_drawer.rs | 4 +++- src/context/quote_block.rs | 6 +++++- src/context/radio_link.rs | 4 +++- src/context/radio_target.rs | 4 +++- src/context/regular_link.rs | 2 ++ src/context/section.rs | 6 +++++- src/context/special_block.rs | 4 +++- src/context/src_block.rs | 2 ++ src/context/statistics_cookie.rs | 4 +++- src/context/strike_through.rs | 6 +++++- src/context/subscript.rs | 4 +++- src/context/superscript.rs | 4 +++- src/context/table.rs | 6 +++++- src/context/target.rs | 2 ++ src/context/timestamp.rs | 4 +++- src/context/underline.rs | 6 +++++- src/context/verbatim.rs | 2 ++ src/context/verse_block.rs | 4 +++- src/intermediate/angle_link.rs | 2 +- src/intermediate/babel_call.rs | 2 +- src/intermediate/bold.rs | 8 +++++++- src/intermediate/center_block.rs | 2 +- src/intermediate/citation.rs | 2 +- src/intermediate/citation_reference.rs | 2 +- src/intermediate/clock.rs | 2 +- src/intermediate/code.rs | 4 ++++ src/intermediate/comment.rs | 2 +- src/intermediate/comment_block.rs | 2 +- src/intermediate/diary_sexp.rs | 2 +- src/intermediate/drawer.rs | 2 +- src/intermediate/dynamic_block.rs | 2 +- src/intermediate/entity.rs | 4 +++- src/intermediate/example_block.rs | 2 +- src/intermediate/export_block.rs | 2 +- src/intermediate/export_snippet.rs | 2 +- src/intermediate/fixed_width_area.rs | 2 +- src/intermediate/footnote_definition.rs | 13 +++++++++---- src/intermediate/footnote_reference.rs | 4 +++- src/intermediate/heading.rs | 4 +++- src/intermediate/horizontal_rule.rs | 2 +- src/intermediate/inline_babel_call.rs | 2 +- src/intermediate/inline_source_block.rs | 4 +++- src/intermediate/italic.rs | 8 +++++++- src/intermediate/keyword.rs | 2 +- src/intermediate/latex_environment.rs | 2 +- src/intermediate/latex_fragment.rs | 8 ++++++-- src/intermediate/line_break.rs | 2 +- src/intermediate/macros.rs | 10 +++++++--- src/intermediate/org_macro.rs | 2 +- src/intermediate/paragraph.rs | 8 ++++++-- src/intermediate/plain_link.rs | 2 +- src/intermediate/plain_list.rs | 4 +++- src/intermediate/plain_text.rs | 4 ++++ src/intermediate/planning.rs | 2 +- src/intermediate/property_drawer.rs | 2 +- src/intermediate/quote_block.rs | 8 ++++++-- src/intermediate/radio_link.rs | 2 +- src/intermediate/radio_target.rs | 2 +- src/intermediate/regular_link.rs | 4 ++++ src/intermediate/section.rs | 8 ++++++-- src/intermediate/special_block.rs | 2 +- src/intermediate/src_block.rs | 9 +++++++-- src/intermediate/statistics_cookie.rs | 2 +- src/intermediate/strike_through.rs | 8 +++++++- src/intermediate/subscript.rs | 2 +- src/intermediate/superscript.rs | 2 +- src/intermediate/table.rs | 8 ++++++-- src/intermediate/target.rs | 4 +++- src/intermediate/timestamp.rs | 5 ++--- src/intermediate/underline.rs | 8 +++++++- src/intermediate/verbatim.rs | 4 ++++ src/intermediate/verse_block.rs | 5 ++--- 108 files changed, 318 insertions(+), 109 deletions(-) diff --git a/src/context/angle_link.rs b/src/context/angle_link.rs index f456e60..243a6a9 100644 --- a/src/context/angle_link.rs +++ b/src/context/angle_link.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "angle_link")] -pub(crate) struct RenderAngleLink {} +pub(crate) struct RenderAngleLink { + post_blank: organic::types::PostBlank, +} rnoop!(RenderAngleLink, IAngleLink); diff --git a/src/context/babel_call.rs b/src/context/babel_call.rs index 9c1fa0d..a888213 100644 --- a/src/context/babel_call.rs +++ b/src/context/babel_call.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "babel_call")] -pub(crate) struct RenderBabelCall {} +pub(crate) struct RenderBabelCall { + post_blank: organic::types::PostBlank, +} rnoop!(RenderBabelCall, IBabelCall); diff --git a/src/context/bold.rs b/src/context/bold.rs index 7049a23..7e2f51f 100644 --- a/src/context/bold.rs +++ b/src/context/bold.rs @@ -12,6 +12,7 @@ use super::RenderObject; #[serde(rename = "bold")] pub(crate) struct RenderBold { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderBold, IBold, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderBold, IBold, original, render_context, { ret }; - Ok(RenderBold { children }) + Ok(RenderBold { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/center_block.rs b/src/context/center_block.rs index 04db135..bcb873a 100644 --- a/src/context/center_block.rs +++ b/src/context/center_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "center_block")] -pub(crate) struct RenderCenterBlock {} +pub(crate) struct RenderCenterBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderCenterBlock, ICenterBlock); diff --git a/src/context/citation.rs b/src/context/citation.rs index c9d44fa..5bd73b5 100644 --- a/src/context/citation.rs +++ b/src/context/citation.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "citation")] -pub(crate) struct RenderCitation {} +pub(crate) struct RenderCitation { + post_blank: organic::types::PostBlank, +} rnoop!(RenderCitation, ICitation); diff --git a/src/context/citation_reference.rs b/src/context/citation_reference.rs index 8c188d4..8203cc2 100644 --- a/src/context/citation_reference.rs +++ b/src/context/citation_reference.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "citation_reference")] -pub(crate) struct RenderCitationReference {} +pub(crate) struct RenderCitationReference { + post_blank: organic::types::PostBlank, +} rnoop!(RenderCitationReference, ICitationReference); diff --git a/src/context/clock.rs b/src/context/clock.rs index a8fe617..84cc613 100644 --- a/src/context/clock.rs +++ b/src/context/clock.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "clock")] -pub(crate) struct RenderClock {} +pub(crate) struct RenderClock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderClock, IClock); diff --git a/src/context/code.rs b/src/context/code.rs index bdce2ac..5149218 100644 --- a/src/context/code.rs +++ b/src/context/code.rs @@ -11,10 +11,12 @@ use super::macros::render; #[serde(rename = "code")] pub(crate) struct RenderCode { contents: String, + post_blank: organic::types::PostBlank, } render!(RenderCode, ICode, original, _render_context, { Ok(RenderCode { contents: original.contents.clone(), + post_blank: original.post_blank, }) }); diff --git a/src/context/comment.rs b/src/context/comment.rs index fbab8e1..4f60095 100644 --- a/src/context/comment.rs +++ b/src/context/comment.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "comment")] -pub(crate) struct RenderComment {} +pub(crate) struct RenderComment { + post_blank: organic::types::PostBlank, +} rnoop!(RenderComment, IComment); diff --git a/src/context/comment_block.rs b/src/context/comment_block.rs index 34702e2..fb707c6 100644 --- a/src/context/comment_block.rs +++ b/src/context/comment_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "comment_block")] -pub(crate) struct RenderCommentBlock {} +pub(crate) struct RenderCommentBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderCommentBlock, ICommentBlock); diff --git a/src/context/diary_sexp.rs b/src/context/diary_sexp.rs index e6235e5..e52a5c1 100644 --- a/src/context/diary_sexp.rs +++ b/src/context/diary_sexp.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "diary_sexp")] -pub(crate) struct RenderDiarySexp {} +pub(crate) struct RenderDiarySexp { + post_blank: organic::types::PostBlank, +} rnoop!(RenderDiarySexp, IDiarySexp); diff --git a/src/context/drawer.rs b/src/context/drawer.rs index a6b7f5e..879144d 100644 --- a/src/context/drawer.rs +++ b/src/context/drawer.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "drawer")] -pub(crate) struct RenderDrawer {} +pub(crate) struct RenderDrawer { + post_blank: organic::types::PostBlank, +} rnoop!(RenderDrawer, IDrawer); diff --git a/src/context/dynamic_block.rs b/src/context/dynamic_block.rs index bf7840f..ae3e2e6 100644 --- a/src/context/dynamic_block.rs +++ b/src/context/dynamic_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "dynamic_block")] -pub(crate) struct RenderDynamicBlock {} +pub(crate) struct RenderDynamicBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderDynamicBlock, IDynamicBlock); diff --git a/src/context/entity.rs b/src/context/entity.rs index a69f24f..6429f7d 100644 --- a/src/context/entity.rs +++ b/src/context/entity.rs @@ -11,10 +11,12 @@ use super::macros::render; #[serde(rename = "entity")] pub(crate) struct RenderEntity { html: String, + post_blank: organic::types::PostBlank, } render!(RenderEntity, IEntity, original, _render_context, { Ok(RenderEntity { html: original.html.clone(), + post_blank: original.post_blank, }) }); diff --git a/src/context/example_block.rs b/src/context/example_block.rs index 464d435..b1c184b 100644 --- a/src/context/example_block.rs +++ b/src/context/example_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "example_block")] -pub(crate) struct RenderExampleBlock {} +pub(crate) struct RenderExampleBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderExampleBlock, IExampleBlock); diff --git a/src/context/export_block.rs b/src/context/export_block.rs index 36e5a06..68df816 100644 --- a/src/context/export_block.rs +++ b/src/context/export_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "export_block")] -pub(crate) struct RenderExportBlock {} +pub(crate) struct RenderExportBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderExportBlock, IExportBlock); diff --git a/src/context/export_snippet.rs b/src/context/export_snippet.rs index 246f25a..c410079 100644 --- a/src/context/export_snippet.rs +++ b/src/context/export_snippet.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "export_snippet")] -pub(crate) struct RenderExportSnippet {} +pub(crate) struct RenderExportSnippet { + post_blank: organic::types::PostBlank, +} rnoop!(RenderExportSnippet, IExportSnippet); diff --git a/src/context/fixed_width_area.rs b/src/context/fixed_width_area.rs index ca9bb7f..5cd08f2 100644 --- a/src/context/fixed_width_area.rs +++ b/src/context/fixed_width_area.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "fixed_width_area")] -pub(crate) struct RenderFixedWidthArea {} +pub(crate) struct RenderFixedWidthArea { + post_blank: organic::types::PostBlank, +} rnoop!(RenderFixedWidthArea, IFixedWidthArea); diff --git a/src/context/footnote_definition.rs b/src/context/footnote_definition.rs index 8077f33..58e0ab0 100644 --- a/src/context/footnote_definition.rs +++ b/src/context/footnote_definition.rs @@ -13,18 +13,21 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "footnote_definition")] -pub(crate) struct RenderFootnoteDefinition {} +pub(crate) struct RenderFootnoteDefinition { + post_blank: organic::types::PostBlank, +} rnoop!(RenderFootnoteDefinition, IFootnoteDefinition); #[derive(Debug, Serialize)] #[serde(tag = "type")] -#[serde(rename = "footnote_reference")] +#[serde(rename = "real_footnote_definition")] pub(crate) struct RenderRealFootnoteDefinition { definition_id: String, reference_link: String, label: String, contents: Vec, + // TODO: Do I need post_blank for real footnote definitions? } render!( diff --git a/src/context/footnote_reference.rs b/src/context/footnote_reference.rs index 28e319d..52ce71f 100644 --- a/src/context/footnote_reference.rs +++ b/src/context/footnote_reference.rs @@ -13,6 +13,7 @@ pub(crate) struct RenderFootnoteReference { reference_id: String, definition_link: String, label: String, + post_blank: organic::types::PostBlank, } render!( @@ -28,6 +29,7 @@ render!( original.get_definition_id(render_context.id_addition) ), label: original.get_display_label(), + post_blank: original.post_blank, }) } ); diff --git a/src/context/heading.rs b/src/context/heading.rs index 9b0064f..6daa5a1 100644 --- a/src/context/heading.rs +++ b/src/context/heading.rs @@ -15,6 +15,7 @@ pub(crate) struct RenderHeading { level: organic::types::HeadlineLevel, title: Vec, children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderHeading, IHeading, original, render_context, { @@ -38,5 +39,6 @@ render!(RenderHeading, IHeading, original, render_context, { level: original.level + 1, // Adding 1 because the page title is going to be h1. title, children, + post_blank: original.post_blank, }) }); diff --git a/src/context/horizontal_rule.rs b/src/context/horizontal_rule.rs index e941eb7..af626e5 100644 --- a/src/context/horizontal_rule.rs +++ b/src/context/horizontal_rule.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "horizontal_rule")] -pub(crate) struct RenderHorizontalRule {} +pub(crate) struct RenderHorizontalRule { + post_blank: organic::types::PostBlank, +} rnoop!(RenderHorizontalRule, IHorizontalRule); diff --git a/src/context/inline_babel_call.rs b/src/context/inline_babel_call.rs index cdbb1ac..56fb575 100644 --- a/src/context/inline_babel_call.rs +++ b/src/context/inline_babel_call.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "inline_babel_call")] -pub(crate) struct RenderInlineBabelCall {} +pub(crate) struct RenderInlineBabelCall { + post_blank: organic::types::PostBlank, +} rnoop!(RenderInlineBabelCall, IInlineBabelCall); diff --git a/src/context/inline_source_block.rs b/src/context/inline_source_block.rs index 79c9710..82a0d4f 100644 --- a/src/context/inline_source_block.rs +++ b/src/context/inline_source_block.rs @@ -11,6 +11,7 @@ use super::macros::render; #[serde(rename = "inline_source_block")] pub(crate) struct RenderInlineSourceBlock { value: String, + post_blank: organic::types::PostBlank, } render!( @@ -21,6 +22,7 @@ render!( { Ok(RenderInlineSourceBlock { value: original.value.clone(), + post_blank: original.post_blank, }) } ); diff --git a/src/context/italic.rs b/src/context/italic.rs index 9c4e995..797c259 100644 --- a/src/context/italic.rs +++ b/src/context/italic.rs @@ -12,6 +12,7 @@ use super::RenderObject; #[serde(rename = "italic")] pub(crate) struct RenderItalic { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderItalic, IItalic, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderItalic, IItalic, original, render_context, { ret }; - Ok(RenderItalic { children }) + Ok(RenderItalic { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/keyword.rs b/src/context/keyword.rs index 17e08e7..82730dc 100644 --- a/src/context/keyword.rs +++ b/src/context/keyword.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "keyword")] -pub(crate) struct RenderKeyword {} +pub(crate) struct RenderKeyword { + post_blank: organic::types::PostBlank, +} rnoop!(RenderKeyword, IKeyword); diff --git a/src/context/latex_environment.rs b/src/context/latex_environment.rs index 72a59e4..bffc3f8 100644 --- a/src/context/latex_environment.rs +++ b/src/context/latex_environment.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "latex_environment")] -pub(crate) struct RenderLatexEnvironment {} +pub(crate) struct RenderLatexEnvironment { + post_blank: organic::types::PostBlank, +} rnoop!(RenderLatexEnvironment, ILatexEnvironment); diff --git a/src/context/latex_fragment.rs b/src/context/latex_fragment.rs index fa695a0..a96f497 100644 --- a/src/context/latex_fragment.rs +++ b/src/context/latex_fragment.rs @@ -11,6 +11,7 @@ use super::macros::render; #[serde(rename = "latex_fragment")] pub(crate) struct RenderLatexFragment { value: String, + post_blank: organic::types::PostBlank, } render!( @@ -21,6 +22,7 @@ render!( { Ok(RenderLatexFragment { value: original.value.clone(), + post_blank: original.post_blank, }) } ); diff --git a/src/context/line_break.rs b/src/context/line_break.rs index 95f8554..86ac482 100644 --- a/src/context/line_break.rs +++ b/src/context/line_break.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "line_break")] -pub(crate) struct RenderLineBreak {} +pub(crate) struct RenderLineBreak { + post_blank: organic::types::PostBlank, +} rnoop!(RenderLineBreak, ILineBreak); diff --git a/src/context/macros.rs b/src/context/macros.rs index 1ed3338..9635f8e 100644 --- a/src/context/macros.rs +++ b/src/context/macros.rs @@ -24,9 +24,11 @@ macro_rules! rnoop { impl $rstruct { pub(crate) fn new( _render_context: RenderContext<'_>, - _original: &$istruct, + original: &$istruct, ) -> Result<$rstruct, CustomError> { - Ok($rstruct {}) + Ok($rstruct { + post_blank: original.post_blank, + }) } } }; diff --git a/src/context/org_macro.rs b/src/context/org_macro.rs index 8c03ff2..9105174 100644 --- a/src/context/org_macro.rs +++ b/src/context/org_macro.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "org_macro")] -pub(crate) struct RenderOrgMacro {} +pub(crate) struct RenderOrgMacro { + post_blank: organic::types::PostBlank, +} rnoop!(RenderOrgMacro, IOrgMacro); diff --git a/src/context/paragraph.rs b/src/context/paragraph.rs index c7bd6e3..9b69ee3 100644 --- a/src/context/paragraph.rs +++ b/src/context/paragraph.rs @@ -12,6 +12,7 @@ use super::RenderObject; #[serde(rename = "paragraph")] pub(crate) struct RenderParagraph { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderParagraph, IParagraph, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderParagraph, IParagraph, original, render_context, { ret }; - Ok(RenderParagraph { children }) + Ok(RenderParagraph { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/plain_link.rs b/src/context/plain_link.rs index a30c77e..897206f 100644 --- a/src/context/plain_link.rs +++ b/src/context/plain_link.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "plain_link")] -pub(crate) struct RenderPlainLink {} +pub(crate) struct RenderPlainLink { + post_blank: organic::types::PostBlank, +} rnoop!(RenderPlainLink, IPlainLink); diff --git a/src/context/plain_list.rs b/src/context/plain_list.rs index 7b6fe69..e5765d1 100644 --- a/src/context/plain_list.rs +++ b/src/context/plain_list.rs @@ -13,6 +13,7 @@ use super::plain_list_item::RenderPlainListItem; pub(crate) struct RenderPlainList { list_type: String, children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderPlainList, IPlainList, original, render_context, { @@ -32,5 +33,6 @@ render!(RenderPlainList, IPlainList, original, render_context, { Ok(RenderPlainList { list_type, children, + post_blank: original.post_blank, }) }); diff --git a/src/context/plain_text.rs b/src/context/plain_text.rs index 134d685..f027694 100644 --- a/src/context/plain_text.rs +++ b/src/context/plain_text.rs @@ -11,10 +11,12 @@ use super::macros::render; #[serde(rename = "plain_text")] pub(crate) struct RenderPlainText { source: String, + post_blank: organic::types::PostBlank, } render!(RenderPlainText, IPlainText, original, _render_context, { Ok(RenderPlainText { source: original.source.clone(), + post_blank: original.post_blank, }) }); diff --git a/src/context/planning.rs b/src/context/planning.rs index 33f8b2c..f454ec3 100644 --- a/src/context/planning.rs +++ b/src/context/planning.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "planning")] -pub(crate) struct RenderPlanning {} +pub(crate) struct RenderPlanning { + post_blank: organic::types::PostBlank, +} rnoop!(RenderPlanning, IPlanning); diff --git a/src/context/property_drawer.rs b/src/context/property_drawer.rs index 69ee47e..cccecac 100644 --- a/src/context/property_drawer.rs +++ b/src/context/property_drawer.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "property_drawer")] -pub(crate) struct RenderPropertyDrawer {} +pub(crate) struct RenderPropertyDrawer { + post_blank: organic::types::PostBlank, +} rnoop!(RenderPropertyDrawer, IPropertyDrawer); diff --git a/src/context/quote_block.rs b/src/context/quote_block.rs index 581cbe2..20edd83 100644 --- a/src/context/quote_block.rs +++ b/src/context/quote_block.rs @@ -12,6 +12,7 @@ use super::RenderElement; #[serde(rename = "quote_block")] pub(crate) struct RenderQuoteBlock { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderQuoteBlock, IQuoteBlock, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderQuoteBlock, IQuoteBlock, original, render_context, { ret }; - Ok(RenderQuoteBlock { children }) + Ok(RenderQuoteBlock { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/radio_link.rs b/src/context/radio_link.rs index a7eabdb..2e48449 100644 --- a/src/context/radio_link.rs +++ b/src/context/radio_link.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "radio_link")] -pub(crate) struct RenderRadioLink {} +pub(crate) struct RenderRadioLink { + post_blank: organic::types::PostBlank, +} rnoop!(RenderRadioLink, IRadioLink); diff --git a/src/context/radio_target.rs b/src/context/radio_target.rs index 5f91d13..f0ba805 100644 --- a/src/context/radio_target.rs +++ b/src/context/radio_target.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "radio_target")] -pub(crate) struct RenderRadioTarget {} +pub(crate) struct RenderRadioTarget { + post_blank: organic::types::PostBlank, +} rnoop!(RenderRadioTarget, IRadioTarget); diff --git a/src/context/regular_link.rs b/src/context/regular_link.rs index 9dfceae..9a84f51 100644 --- a/src/context/regular_link.rs +++ b/src/context/regular_link.rs @@ -13,6 +13,7 @@ use super::RenderObject; pub(crate) struct RenderRegularLink { raw_link: String, children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderRegularLink, IRegularLink, original, render_context, { @@ -27,5 +28,6 @@ render!(RenderRegularLink, IRegularLink, original, render_context, { Ok(RenderRegularLink { raw_link: original.raw_link.clone(), children, + post_blank: original.post_blank, }) }); diff --git a/src/context/section.rs b/src/context/section.rs index aa297c3..9e69f0f 100644 --- a/src/context/section.rs +++ b/src/context/section.rs @@ -12,6 +12,7 @@ use super::RenderElement; #[serde(rename = "section")] pub(crate) struct RenderSection { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderSection, ISection, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderSection, ISection, original, render_context, { ret }; - Ok(RenderSection { children }) + Ok(RenderSection { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/special_block.rs b/src/context/special_block.rs index 21f96fc..5b46e9c 100644 --- a/src/context/special_block.rs +++ b/src/context/special_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "special_block")] -pub(crate) struct RenderSpecialBlock {} +pub(crate) struct RenderSpecialBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderSpecialBlock, ISpecialBlock); diff --git a/src/context/src_block.rs b/src/context/src_block.rs index bc9451a..2f6298d 100644 --- a/src/context/src_block.rs +++ b/src/context/src_block.rs @@ -12,11 +12,13 @@ use super::macros::render; pub(crate) struct RenderSrcBlock { lines: Vec, language: Option, + post_blank: organic::types::PostBlank, } render!(RenderSrcBlock, ISrcBlock, original, _render_context, { Ok(RenderSrcBlock { lines: original.lines.clone(), language: original.language.clone(), + post_blank: original.post_blank, }) }); diff --git a/src/context/statistics_cookie.rs b/src/context/statistics_cookie.rs index ca71b95..9326819 100644 --- a/src/context/statistics_cookie.rs +++ b/src/context/statistics_cookie.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "statistics_cookie")] -pub(crate) struct RenderStatisticsCookie {} +pub(crate) struct RenderStatisticsCookie { + post_blank: organic::types::PostBlank, +} rnoop!(RenderStatisticsCookie, IStatisticsCookie); diff --git a/src/context/strike_through.rs b/src/context/strike_through.rs index 1d53f9c..ac578bf 100644 --- a/src/context/strike_through.rs +++ b/src/context/strike_through.rs @@ -12,6 +12,7 @@ use super::RenderObject; #[serde(rename = "strike_through")] pub(crate) struct RenderStrikeThrough { children: Vec, + post_blank: organic::types::PostBlank, } render!( @@ -28,6 +29,9 @@ render!( ret }; - Ok(RenderStrikeThrough { children }) + Ok(RenderStrikeThrough { + children, + post_blank: original.post_blank, + }) } ); diff --git a/src/context/subscript.rs b/src/context/subscript.rs index 359492c..4efabdf 100644 --- a/src/context/subscript.rs +++ b/src/context/subscript.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "subscript")] -pub(crate) struct RenderSubscript {} +pub(crate) struct RenderSubscript { + post_blank: organic::types::PostBlank, +} rnoop!(RenderSubscript, ISubscript); diff --git a/src/context/superscript.rs b/src/context/superscript.rs index 3af3340..d18e60d 100644 --- a/src/context/superscript.rs +++ b/src/context/superscript.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "superscript")] -pub(crate) struct RenderSuperscript {} +pub(crate) struct RenderSuperscript { + post_blank: organic::types::PostBlank, +} rnoop!(RenderSuperscript, ISuperscript); diff --git a/src/context/table.rs b/src/context/table.rs index d1af62f..045d7a6 100644 --- a/src/context/table.rs +++ b/src/context/table.rs @@ -12,6 +12,7 @@ use super::table_row::RenderTableRow; #[serde(rename = "table")] pub(crate) struct RenderTable { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderTable, ITable, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderTable, ITable, original, render_context, { ret }; - Ok(RenderTable { children }) + Ok(RenderTable { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/target.rs b/src/context/target.rs index 458bc69..5d9fede 100644 --- a/src/context/target.rs +++ b/src/context/target.rs @@ -11,10 +11,12 @@ use super::macros::render; #[serde(rename = "target")] pub(crate) struct RenderTarget { id: String, + post_blank: organic::types::PostBlank, } render!(RenderTarget, ITarget, original, _render_context, { Ok(RenderTarget { id: original.id.clone(), + post_blank: original.post_blank, }) }); diff --git a/src/context/timestamp.rs b/src/context/timestamp.rs index cf5ce54..c5f15b7 100644 --- a/src/context/timestamp.rs +++ b/src/context/timestamp.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "timestamp")] -pub(crate) struct RenderTimestamp {} +pub(crate) struct RenderTimestamp { + post_blank: organic::types::PostBlank, +} rnoop!(RenderTimestamp, ITimestamp); diff --git a/src/context/underline.rs b/src/context/underline.rs index ab5fa5a..c1f1ce2 100644 --- a/src/context/underline.rs +++ b/src/context/underline.rs @@ -12,6 +12,7 @@ use super::RenderObject; #[serde(rename = "underline")] pub(crate) struct RenderUnderline { children: Vec, + post_blank: organic::types::PostBlank, } render!(RenderUnderline, IUnderline, original, render_context, { @@ -23,5 +24,8 @@ render!(RenderUnderline, IUnderline, original, render_context, { ret }; - Ok(RenderUnderline { children }) + Ok(RenderUnderline { + children, + post_blank: original.post_blank, + }) }); diff --git a/src/context/verbatim.rs b/src/context/verbatim.rs index 68d2d0d..3324aa7 100644 --- a/src/context/verbatim.rs +++ b/src/context/verbatim.rs @@ -11,10 +11,12 @@ use super::macros::render; #[serde(rename = "verbatim")] pub(crate) struct RenderVerbatim { contents: String, + post_blank: organic::types::PostBlank, } render!(RenderVerbatim, IVerbatim, original, _render_context, { Ok(RenderVerbatim { contents: original.contents.clone(), + post_blank: original.post_blank, }) }); diff --git a/src/context/verse_block.rs b/src/context/verse_block.rs index cea5eb5..3816ac2 100644 --- a/src/context/verse_block.rs +++ b/src/context/verse_block.rs @@ -9,6 +9,8 @@ use super::macros::rnoop; #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "verse_block")] -pub(crate) struct RenderVerseBlock {} +pub(crate) struct RenderVerseBlock { + post_blank: organic::types::PostBlank, +} rnoop!(RenderVerseBlock, IVerseBlock); diff --git a/src/intermediate/angle_link.rs b/src/intermediate/angle_link.rs index 8852e4e..00bccad 100644 --- a/src/intermediate/angle_link.rs +++ b/src/intermediate/angle_link.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IAngleLink, AngleLink); diff --git a/src/intermediate/babel_call.rs b/src/intermediate/babel_call.rs index 62d5757..a7589d7 100644 --- a/src/intermediate/babel_call.rs +++ b/src/intermediate/babel_call.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IBabelCall, BabelCall); diff --git a/src/intermediate/bold.rs b/src/intermediate/bold.rs index 7d7e751..d7d9ada 100644 --- a/src/intermediate/bold.rs +++ b/src/intermediate/bold.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use super::IObject; @@ -6,6 +8,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct IBold { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +25,9 @@ intermediate!( ret }; - Ok(IBold { children }) + Ok(IBold { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/center_block.rs b/src/intermediate/center_block.rs index 14541d3..d92bf4f 100644 --- a/src/intermediate/center_block.rs +++ b/src/intermediate/center_block.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ICenterBlock, CenterBlock); diff --git a/src/intermediate/citation.rs b/src/intermediate/citation.rs index e4971b0..206013a 100644 --- a/src/intermediate/citation.rs +++ b/src/intermediate/citation.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ICitation, Citation); diff --git a/src/intermediate/citation_reference.rs b/src/intermediate/citation_reference.rs index 1d4b955..e03593f 100644 --- a/src/intermediate/citation_reference.rs +++ b/src/intermediate/citation_reference.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ICitationReference, CitationReference); diff --git a/src/intermediate/clock.rs b/src/intermediate/clock.rs index 53f878f..29232b8 100644 --- a/src/intermediate/clock.rs +++ b/src/intermediate/clock.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IClock, Clock); diff --git a/src/intermediate/code.rs b/src/intermediate/code.rs index d166683..be0d73a 100644 --- a/src/intermediate/code.rs +++ b/src/intermediate/code.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use crate::error::CustomError; @@ -5,6 +7,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct ICode { pub(crate) contents: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -16,6 +19,7 @@ intermediate!( Ok(ICode { // TODO: Should this coalesce whitespace like PlainText? contents: original.contents.to_owned(), + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/comment.rs b/src/intermediate/comment.rs index 1a36791..a2db760 100644 --- a/src/intermediate/comment.rs +++ b/src/intermediate/comment.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IComment, Comment); diff --git a/src/intermediate/comment_block.rs b/src/intermediate/comment_block.rs index a65d6b4..29ab37a 100644 --- a/src/intermediate/comment_block.rs +++ b/src/intermediate/comment_block.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ICommentBlock, CommentBlock); diff --git a/src/intermediate/diary_sexp.rs b/src/intermediate/diary_sexp.rs index e256852..67b8662 100644 --- a/src/intermediate/diary_sexp.rs +++ b/src/intermediate/diary_sexp.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IDiarySexp, DiarySexp); diff --git a/src/intermediate/drawer.rs b/src/intermediate/drawer.rs index 9b23719..d6939b3 100644 --- a/src/intermediate/drawer.rs +++ b/src/intermediate/drawer.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IDrawer, Drawer); diff --git a/src/intermediate/dynamic_block.rs b/src/intermediate/dynamic_block.rs index 3094839..f3622ac 100644 --- a/src/intermediate/dynamic_block.rs +++ b/src/intermediate/dynamic_block.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IDynamicBlock, DynamicBlock); diff --git a/src/intermediate/entity.rs b/src/intermediate/entity.rs index 11dff6d..3d69295 100644 --- a/src/intermediate/entity.rs +++ b/src/intermediate/entity.rs @@ -1,10 +1,11 @@ use super::macros::intermediate; - use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IEntity { pub(crate) html: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -15,6 +16,7 @@ intermediate!( { Ok(IEntity { html: original.html.to_owned(), + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/example_block.rs b/src/intermediate/example_block.rs index bcb00c0..24e8690 100644 --- a/src/intermediate/example_block.rs +++ b/src/intermediate/example_block.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IExampleBlock, ExampleBlock); diff --git a/src/intermediate/export_block.rs b/src/intermediate/export_block.rs index d2b001f..34b8b96 100644 --- a/src/intermediate/export_block.rs +++ b/src/intermediate/export_block.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IExportBlock, ExportBlock); diff --git a/src/intermediate/export_snippet.rs b/src/intermediate/export_snippet.rs index 4534303..30a3447 100644 --- a/src/intermediate/export_snippet.rs +++ b/src/intermediate/export_snippet.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IExportSnippet, ExportSnippet); diff --git a/src/intermediate/fixed_width_area.rs b/src/intermediate/fixed_width_area.rs index ef6db8e..ffd26e0 100644 --- a/src/intermediate/fixed_width_area.rs +++ b/src/intermediate/fixed_width_area.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IFixedWidthArea, FixedWidthArea); diff --git a/src/intermediate/footnote_definition.rs b/src/intermediate/footnote_definition.rs index bef6779..1d612e5 100644 --- a/src/intermediate/footnote_definition.rs +++ b/src/intermediate/footnote_definition.rs @@ -1,12 +1,14 @@ use super::macros::intermediate; use super::registry::register_footnote_definition; -use super::IntermediateContext; - use super::IAstNode; +use super::IntermediateContext; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] -pub(crate) struct IFootnoteDefinition {} +pub(crate) struct IFootnoteDefinition { + pub(crate) post_blank: organic::types::PostBlank, +} intermediate!( IFootnoteDefinition, @@ -16,12 +18,15 @@ intermediate!( { register_footnote_definition(intermediate_context, original.label, &original.children) .await?; - Ok(IFootnoteDefinition {}) + Ok(IFootnoteDefinition { + post_blank: original.get_post_blank(), + }) } ); #[derive(Debug)] pub(crate) struct IRealFootnoteDefinition { + // TODO: Do I need post_blank for the real footnote definitions? pub(crate) footnote_id: usize, pub(crate) contents: Vec, } diff --git a/src/intermediate/footnote_reference.rs b/src/intermediate/footnote_reference.rs index 5aef79d..75dac0f 100644 --- a/src/intermediate/footnote_reference.rs +++ b/src/intermediate/footnote_reference.rs @@ -1,12 +1,13 @@ use super::macros::intermediate; use super::registry::get_footnote_reference_id; - use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IFootnoteReference { footnote_id: usize, duplicate_offset: usize, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -21,6 +22,7 @@ intermediate!( Ok(IFootnoteReference { footnote_id, duplicate_offset: reference_count, + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/heading.rs b/src/intermediate/heading.rs index fbaba46..5cc8f04 100644 --- a/src/intermediate/heading.rs +++ b/src/intermediate/heading.rs @@ -1,14 +1,15 @@ use super::macros::intermediate; - use super::IDocumentElement; use super::IObject; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IHeading { pub(crate) level: organic::types::HeadlineLevel, pub(crate) title: Vec, pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -35,6 +36,7 @@ intermediate!( title, level: original.level, children, + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/horizontal_rule.rs b/src/intermediate/horizontal_rule.rs index 8a2d342..7927fdc 100644 --- a/src/intermediate/horizontal_rule.rs +++ b/src/intermediate/horizontal_rule.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IHorizontalRule, HorizontalRule); diff --git a/src/intermediate/inline_babel_call.rs b/src/intermediate/inline_babel_call.rs index 2f60310..3ea7aef 100644 --- a/src/intermediate/inline_babel_call.rs +++ b/src/intermediate/inline_babel_call.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IInlineBabelCall, InlineBabelCall); diff --git a/src/intermediate/inline_source_block.rs b/src/intermediate/inline_source_block.rs index ab32a9c..6c62f26 100644 --- a/src/intermediate/inline_source_block.rs +++ b/src/intermediate/inline_source_block.rs @@ -1,10 +1,11 @@ use super::macros::intermediate; - use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IInlineSourceBlock { pub(crate) value: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -15,6 +16,7 @@ intermediate!( { Ok(IInlineSourceBlock { value: original.value.to_owned(), + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/italic.rs b/src/intermediate/italic.rs index 44bb165..350cf14 100644 --- a/src/intermediate/italic.rs +++ b/src/intermediate/italic.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use super::IObject; @@ -6,6 +8,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct IItalic { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +25,9 @@ intermediate!( ret }; - Ok(IItalic { children }) + Ok(IItalic { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/keyword.rs b/src/intermediate/keyword.rs index d282bb4..7ec06fb 100644 --- a/src/intermediate/keyword.rs +++ b/src/intermediate/keyword.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IKeyword, Keyword); diff --git a/src/intermediate/latex_environment.rs b/src/intermediate/latex_environment.rs index 891f570..1b4480e 100644 --- a/src/intermediate/latex_environment.rs +++ b/src/intermediate/latex_environment.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ILatexEnvironment, LatexEnvironment); diff --git a/src/intermediate/latex_fragment.rs b/src/intermediate/latex_fragment.rs index ee4195d..beab9b6 100644 --- a/src/intermediate/latex_fragment.rs +++ b/src/intermediate/latex_fragment.rs @@ -1,10 +1,11 @@ use super::macros::intermediate; - use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct ILatexFragment { pub(crate) value: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -20,6 +21,9 @@ intermediate!( } else { original.value.to_owned() }; - Ok(ILatexFragment { value }) + Ok(ILatexFragment { + value, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/line_break.rs b/src/intermediate/line_break.rs index a092d54..5a62df1 100644 --- a/src/intermediate/line_break.rs +++ b/src/intermediate/line_break.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ILineBreak, LineBreak); diff --git a/src/intermediate/macros.rs b/src/intermediate/macros.rs index 8b9623f..54f877e 100644 --- a/src/intermediate/macros.rs +++ b/src/intermediate/macros.rs @@ -4,14 +4,18 @@ macro_rules! inoop { ($istruct:ident, $pstruct:ident) => { #[derive(Debug, Clone)] - pub(crate) struct $istruct {} + pub(crate) struct $istruct { + pub(crate) post_blank: organic::types::PostBlank, + } impl $istruct { pub(crate) async fn new<'reg, 'orig, 'parse>( _intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, - _original: &'orig organic::types::$pstruct<'parse>, + original: &'orig organic::types::$pstruct<'parse>, ) -> Result<$istruct, CustomError> { - Ok($istruct {}) + Ok($istruct { + post_blank: original.get_post_blank(), + }) } } }; diff --git a/src/intermediate/org_macro.rs b/src/intermediate/org_macro.rs index ffc56d3..f1a158f 100644 --- a/src/intermediate/org_macro.rs +++ b/src/intermediate/org_macro.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IOrgMacro, OrgMacro); diff --git a/src/intermediate/paragraph.rs b/src/intermediate/paragraph.rs index a93eb57..0b3adac 100644 --- a/src/intermediate/paragraph.rs +++ b/src/intermediate/paragraph.rs @@ -1,11 +1,12 @@ use super::macros::intermediate; - use super::IObject; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IParagraph { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +23,9 @@ intermediate!( ret }; - Ok(IParagraph { children }) + Ok(IParagraph { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/plain_link.rs b/src/intermediate/plain_link.rs index 0178945..0a53e79 100644 --- a/src/intermediate/plain_link.rs +++ b/src/intermediate/plain_link.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IPlainLink, PlainLink); diff --git a/src/intermediate/plain_list.rs b/src/intermediate/plain_list.rs index 063305e..62f834b 100644 --- a/src/intermediate/plain_list.rs +++ b/src/intermediate/plain_list.rs @@ -1,12 +1,13 @@ use super::macros::intermediate; - use super::IPlainListItem; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IPlainList { pub(crate) list_type: organic::types::PlainListType, pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -26,6 +27,7 @@ intermediate!( Ok(IPlainList { list_type: original.list_type, children, + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/plain_text.rs b/src/intermediate/plain_text.rs index a346cbe..462c778 100644 --- a/src/intermediate/plain_text.rs +++ b/src/intermediate/plain_text.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use super::util::coalesce_whitespace; @@ -6,6 +8,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct IPlainText { pub(crate) source: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -16,6 +19,7 @@ intermediate!( { Ok(IPlainText { source: coalesce_whitespace(original.source).into_owned(), + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/planning.rs b/src/intermediate/planning.rs index 56cee1a..b265614 100644 --- a/src/intermediate/planning.rs +++ b/src/intermediate/planning.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IPlanning, Planning); diff --git a/src/intermediate/property_drawer.rs b/src/intermediate/property_drawer.rs index 835cc69..217ef8f 100644 --- a/src/intermediate/property_drawer.rs +++ b/src/intermediate/property_drawer.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IPropertyDrawer, PropertyDrawer); diff --git a/src/intermediate/quote_block.rs b/src/intermediate/quote_block.rs index 68daeda..e4e6f5d 100644 --- a/src/intermediate/quote_block.rs +++ b/src/intermediate/quote_block.rs @@ -1,11 +1,12 @@ use super::macros::intermediate; - use super::IElement; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct IQuoteBlock { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +23,9 @@ intermediate!( ret }; - Ok(IQuoteBlock { children }) + Ok(IQuoteBlock { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/radio_link.rs b/src/intermediate/radio_link.rs index f51f0b0..98f6bc8 100644 --- a/src/intermediate/radio_link.rs +++ b/src/intermediate/radio_link.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IRadioLink, RadioLink); diff --git a/src/intermediate/radio_target.rs b/src/intermediate/radio_target.rs index 9c56e2f..5d5db5a 100644 --- a/src/intermediate/radio_target.rs +++ b/src/intermediate/radio_target.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IRadioTarget, RadioTarget); diff --git a/src/intermediate/regular_link.rs b/src/intermediate/regular_link.rs index 14262ee..2b2c249 100644 --- a/src/intermediate/regular_link.rs +++ b/src/intermediate/regular_link.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use super::IObject; @@ -7,6 +9,7 @@ use crate::error::CustomError; pub(crate) struct IRegularLink { pub(crate) raw_link: String, pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -25,6 +28,7 @@ intermediate!( Ok(IRegularLink { raw_link: original.get_raw_link().into_owned(), children, + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/section.rs b/src/intermediate/section.rs index defca30..089eb4e 100644 --- a/src/intermediate/section.rs +++ b/src/intermediate/section.rs @@ -1,11 +1,12 @@ use super::macros::intermediate; - use super::IElement; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct ISection { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +23,9 @@ intermediate!( ret }; - Ok(ISection { children }) + Ok(ISection { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/special_block.rs b/src/intermediate/special_block.rs index de07572..b97da8a 100644 --- a/src/intermediate/special_block.rs +++ b/src/intermediate/special_block.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ISpecialBlock, SpecialBlock); diff --git a/src/intermediate/src_block.rs b/src/intermediate/src_block.rs index 6bc9ef0..b0d948b 100644 --- a/src/intermediate/src_block.rs +++ b/src/intermediate/src_block.rs @@ -1,11 +1,12 @@ use super::macros::intermediate; - use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct ISrcBlock { pub(crate) lines: Vec, pub(crate) language: Option, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -58,7 +59,11 @@ intermediate!( }) .collect(); let language = original.language.map(str::to_owned); - Ok(ISrcBlock { lines, language }) + Ok(ISrcBlock { + lines, + language, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/statistics_cookie.rs b/src/intermediate/statistics_cookie.rs index 1c6c115..6de55ba 100644 --- a/src/intermediate/statistics_cookie.rs +++ b/src/intermediate/statistics_cookie.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IStatisticsCookie, StatisticsCookie); diff --git a/src/intermediate/strike_through.rs b/src/intermediate/strike_through.rs index 151a4ee..3e8a6bc 100644 --- a/src/intermediate/strike_through.rs +++ b/src/intermediate/strike_through.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use super::IObject; @@ -6,6 +8,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct IStrikeThrough { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +25,9 @@ intermediate!( ret }; - Ok(IStrikeThrough { children }) + Ok(IStrikeThrough { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/subscript.rs b/src/intermediate/subscript.rs index e45c784..81b9ebc 100644 --- a/src/intermediate/subscript.rs +++ b/src/intermediate/subscript.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ISubscript, Subscript); diff --git a/src/intermediate/superscript.rs b/src/intermediate/superscript.rs index 80501ab..775b489 100644 --- a/src/intermediate/superscript.rs +++ b/src/intermediate/superscript.rs @@ -1,5 +1,5 @@ use super::macros::inoop; - use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ISuperscript, Superscript); diff --git a/src/intermediate/table.rs b/src/intermediate/table.rs index cc99add..c52977e 100644 --- a/src/intermediate/table.rs +++ b/src/intermediate/table.rs @@ -1,11 +1,12 @@ use super::macros::intermediate; - use super::table_row::ITableRow; use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct ITable { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +23,9 @@ intermediate!( ret }; - Ok(ITable { children }) + Ok(ITable { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/target.rs b/src/intermediate/target.rs index 3030fe9..e172164 100644 --- a/src/intermediate/target.rs +++ b/src/intermediate/target.rs @@ -1,11 +1,12 @@ use super::macros::intermediate; - use crate::error::CustomError; +use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct ITarget { pub(crate) id: String, value: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -19,6 +20,7 @@ intermediate!( Ok(ITarget { id: id.clone(), value: original.value.to_owned(), + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/timestamp.rs b/src/intermediate/timestamp.rs index 3ab13ac..3fcd45b 100644 --- a/src/intermediate/timestamp.rs +++ b/src/intermediate/timestamp.rs @@ -1,6 +1,5 @@ -use crate::error::CustomError; - use super::macros::inoop; - +use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(ITimestamp, Timestamp); diff --git a/src/intermediate/underline.rs b/src/intermediate/underline.rs index ebbde2f..d30d2c3 100644 --- a/src/intermediate/underline.rs +++ b/src/intermediate/underline.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use super::IObject; @@ -6,6 +8,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct IUnderline { pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -22,6 +25,9 @@ intermediate!( ret }; - Ok(IUnderline { children }) + Ok(IUnderline { + children, + post_blank: original.get_post_blank(), + }) } ); diff --git a/src/intermediate/verbatim.rs b/src/intermediate/verbatim.rs index 787c244..a820bec 100644 --- a/src/intermediate/verbatim.rs +++ b/src/intermediate/verbatim.rs @@ -1,3 +1,5 @@ +use organic::types::StandardProperties; + use super::macros::intermediate; use crate::error::CustomError; @@ -5,6 +7,7 @@ use crate::error::CustomError; #[derive(Debug, Clone)] pub(crate) struct IVerbatim { pub(crate) contents: String, + pub(crate) post_blank: organic::types::PostBlank, } intermediate!( @@ -16,6 +19,7 @@ intermediate!( Ok(IVerbatim { // TODO: Should this coalesce whitespace like PlainText? contents: original.contents.to_owned(), + post_blank: original.get_post_blank(), }) } ); diff --git a/src/intermediate/verse_block.rs b/src/intermediate/verse_block.rs index 2013ead..4ff1615 100644 --- a/src/intermediate/verse_block.rs +++ b/src/intermediate/verse_block.rs @@ -1,6 +1,5 @@ -use crate::error::CustomError; - use super::macros::inoop; - +use crate::error::CustomError; +use organic::types::StandardProperties; inoop!(IVerseBlock, VerseBlock); From 5af4a372ae23436cedc4556ad13acce1091461c3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 15:13:07 -0500 Subject: [PATCH 11/22] Make object trailing space dependent on post_blank. --- default_environment/templates/html/object.dust | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/default_environment/templates/html/object.dust b/default_environment/templates/html/object.dust index 0e094d8..41e026a 100644 --- a/default_environment/templates/html/object.dust +++ b/default_environment/templates/html/object.dust @@ -27,5 +27,4 @@ {@eq value="superscript"}{>superscript/}{/eq} {@eq value="timestamp"}{>timestamp/}{/eq} {@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none} -{/select}{~s} -{! TODO: Maybe the final space should be conditional on end blank in the org source !} +{/select}{@gt key=.post_blank value=0}{~s}{/gt} From efbf6cfc0ce911bcce2cc88f50187768e78bf43a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 15:31:13 -0500 Subject: [PATCH 12/22] Style ordered and unordered plain lists. --- default_environment/stylesheet/main.css | 16 ++++++++++++++++ .../templates/html/plain_list.dust | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 8b0708a..29b6d0f 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -103,6 +103,22 @@ body { font-size: 1.5rem; font-weight: 500; } + + .plain_list { + &.unordered { + list-style-type: disc; + padding-left: 2.5rem; + } + + &.ordered { + list-style-type: decimal; + padding-left: 2.5rem; + } + + &.descriptive { + + } + } } /* A stand-alone blog post (not in a blog stream). */ diff --git a/default_environment/templates/html/plain_list.dust b/default_environment/templates/html/plain_list.dust index fdc240e..8170515 100644 --- a/default_environment/templates/html/plain_list.dust +++ b/default_environment/templates/html/plain_list.dust @@ -1,6 +1,6 @@ {@select key=.list_type} - {@eq value="unordered"}
    {#.children}{>plain_list_item/}{/.children}
{/eq} - {@eq value="ordered"}
    {#.children}{>plain_list_item/}{/.children}
{/eq} - {@eq value="descriptive"}
{#.children}{>plain_list_item/}{/.children}
{/eq} + {@eq value="unordered"}
    {#.children}{>plain_list_item/}{/.children}
{/eq} + {@eq value="ordered"}
    {#.children}{>plain_list_item/}{/.children}
{/eq} + {@eq value="descriptive"}
{#.children}{>plain_list_item/}{/.children}
{/eq} {@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none} {/select} From 775c88d67a7b641918682990052e7cad1cf04104 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 15:44:56 -0500 Subject: [PATCH 13/22] Style footnotes. --- default_environment/stylesheet/main.css | 17 +++++++++++++++++ .../templates/html/footnote_reference.dust | 2 +- .../html/real_footnote_definition.dust | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 29b6d0f..b1944f1 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -119,6 +119,23 @@ body { } } + + .footnote_reference { + vertical-align: super; + font-size: 80%; + > a { + text-decoration: none; + } + } + + .footnote_definition { + .label { + text-decoration: none; + } + .definition { + display: inline; + } + } } /* A stand-alone blog post (not in a blog stream). */ diff --git a/default_environment/templates/html/footnote_reference.dust b/default_environment/templates/html/footnote_reference.dust index a218064..133cb48 100644 --- a/default_environment/templates/html/footnote_reference.dust +++ b/default_environment/templates/html/footnote_reference.dust @@ -1 +1 @@ -{.label} +{.label} diff --git a/default_environment/templates/html/real_footnote_definition.dust b/default_environment/templates/html/real_footnote_definition.dust index 9c6be4b..d70a71f 100644 --- a/default_environment/templates/html/real_footnote_definition.dust +++ b/default_environment/templates/html/real_footnote_definition.dust @@ -1 +1 @@ -
{.label}
{#.contents}{>ast_node/}{/.contents}
+
{.label}.
{#.contents}{>ast_node/}{/.contents}
From 45a1076d181bfc7e581882f8b819c453df3a3a61 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 16:39:26 -0500 Subject: [PATCH 14/22] Style descriptive plain lists. --- default_environment/stylesheet/main.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index b1944f1..3e5e904 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -116,7 +116,14 @@ body { } &.descriptive { + font-size: 1rem; + > dt { + font-weight: 600; + } + > dd { + padding-left: 2.5rem; + } } } From 6f049e00d4bbd4fb7c74911542d3da8d8831544e Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 16:42:22 -0500 Subject: [PATCH 15/22] Style inline source blocks. --- default_environment/stylesheet/main.css | 9 ++++++++- .../templates/html/inline_source_block.dust | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 3e5e904..0839d5d 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -5,6 +5,8 @@ --site-text-color: #fffffc; --header-divider-color: #6a687a; + --src-font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace; + --src-block-background-color: #141414; --src-block-border-color: #84828f; --src-block-language-color: #0a0a0a; @@ -61,7 +63,7 @@ body { border-radius: 3px; border: 1px solid var(--src-block-border-color); font-size: 1rem; - font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace; + font-family: var(--src-font-family); margin: 1rem 0; .src_language { @@ -83,6 +85,11 @@ body { } } + .inline_source_block { + font-family: var(--src-font-family); + font-size: 1rem; + } + .quote_block { border-left: 1px solid var(--quote-block-border-color); padding: 0 0 0 1rem; diff --git a/default_environment/templates/html/inline_source_block.dust b/default_environment/templates/html/inline_source_block.dust index 85ced05..b600bcf 100644 --- a/default_environment/templates/html/inline_source_block.dust +++ b/default_environment/templates/html/inline_source_block.dust @@ -1 +1 @@ -{.value} +{.value} From a8969f141db5b7ea91acc576ebd791082931adec Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 16:49:44 -0500 Subject: [PATCH 16/22] Style code and verbatim. --- default_environment/stylesheet/main.css | 5 +++++ default_environment/templates/html/code.dust | 2 +- default_environment/templates/html/verbatim.dust | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 0839d5d..a93bd1c 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -90,6 +90,11 @@ body { font-size: 1rem; } + .code, .verbatim { + font-family: var(--src-font-family); + font-size: 1rem; + } + .quote_block { border-left: 1px solid var(--quote-block-border-color); padding: 0 0 0 1rem; diff --git a/default_environment/templates/html/code.dust b/default_environment/templates/html/code.dust index 07d701a..104778f 100644 --- a/default_environment/templates/html/code.dust +++ b/default_environment/templates/html/code.dust @@ -1 +1 @@ -{.contents} +{.contents} diff --git a/default_environment/templates/html/verbatim.dust b/default_environment/templates/html/verbatim.dust index 07d701a..9adf09c 100644 --- a/default_environment/templates/html/verbatim.dust +++ b/default_environment/templates/html/verbatim.dust @@ -1 +1 @@ -{.contents} +{.contents} From 2914e42ba102d517bafb242ceb1d11f3ac6b6ba6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 17:18:51 -0500 Subject: [PATCH 17/22] For plain list items with a single child that is a paragraph, do not wrap in paragraph html tags. This is mimicking the behavior from org-mode's HTML exporter. --- .../templates/html/element.dust | 1 + .../html/plain_list_simple_item.dust | 3 ++ src/context/element.rs | 5 +++ src/context/mod.rs | 1 + src/context/plain_list_simple_item.rs | 38 +++++++++++++++++++ src/intermediate/element.rs | 2 + src/intermediate/mod.rs | 2 + src/intermediate/plain_list_item.rs | 16 +++++++- src/intermediate/plain_list_simple_item.rs | 32 ++++++++++++++++ src/main.rs | 1 + 10 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 default_environment/templates/html/plain_list_simple_item.dust create mode 100644 src/context/plain_list_simple_item.rs create mode 100644 src/intermediate/plain_list_simple_item.rs diff --git a/default_environment/templates/html/element.dust b/default_environment/templates/html/element.dust index 81f0ca7..54f8359 100644 --- a/default_environment/templates/html/element.dust +++ b/default_environment/templates/html/element.dust @@ -1,6 +1,7 @@ {@select key=.type} {@eq value="paragraph"}{>paragraph/}{/eq} {@eq value="plain_list"}{>plain_list/}{/eq} + {@eq value="plain_list_simple_item"}{>plain_list_simple_item/}{/eq} {@eq value="center_block"}{>center_block/}{/eq} {@eq value="quote_block"}{>quote_block/}{/eq} {@eq value="special_block"}{>special_block/}{/eq} diff --git a/default_environment/templates/html/plain_list_simple_item.dust b/default_environment/templates/html/plain_list_simple_item.dust new file mode 100644 index 0000000..aa49c92 --- /dev/null +++ b/default_environment/templates/html/plain_list_simple_item.dust @@ -0,0 +1,3 @@ +{#.children} + {>object/} +{/.children} diff --git a/src/context/element.rs b/src/context/element.rs index f493919..dabc80c 100644 --- a/src/context/element.rs +++ b/src/context/element.rs @@ -1,5 +1,6 @@ use serde::Serialize; +use super::plain_list_simple_item::RenderPlainListSimpleItem; use super::render_context::RenderContext; use crate::error::CustomError; use crate::intermediate::IElement; @@ -35,6 +36,7 @@ use super::verse_block::RenderVerseBlock; pub(crate) enum RenderElement { Paragraph(RenderParagraph), PlainList(RenderPlainList), + PlainListSimpleItem(RenderPlainListSimpleItem), CenterBlock(RenderCenterBlock), QuoteBlock(RenderQuoteBlock), SpecialBlock(RenderSpecialBlock), @@ -69,6 +71,9 @@ render!(RenderElement, IElement, original, render_context, { render_context.clone(), inner, )?)), + IElement::PlainListSimpleItem(inner) => Ok(RenderElement::PlainListSimpleItem( + RenderPlainListSimpleItem::new(render_context.clone(), inner)?, + )), IElement::CenterBlock(inner) => Ok(RenderElement::CenterBlock(RenderCenterBlock::new( render_context.clone(), inner, diff --git a/src/context/mod.rs b/src/context/mod.rs index 99ff45c..adff5cf 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -41,6 +41,7 @@ mod paragraph; mod plain_link; mod plain_list; mod plain_list_item; +mod plain_list_simple_item; mod plain_text; mod planning; mod property_drawer; diff --git a/src/context/plain_list_simple_item.rs b/src/context/plain_list_simple_item.rs new file mode 100644 index 0000000..1b03208 --- /dev/null +++ b/src/context/plain_list_simple_item.rs @@ -0,0 +1,38 @@ +use serde::Serialize; + +use super::render_context::RenderContext; +use crate::error::CustomError; +use crate::intermediate::IPlainListSimpleItem; + +use super::macros::render; +use super::RenderObject; + +/// Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. +#[derive(Debug, Serialize)] +#[serde(tag = "type")] +#[serde(rename = "plain_list_simple_item")] +pub(crate) struct RenderPlainListSimpleItem { + children: Vec, + post_blank: organic::types::PostBlank, +} + +render!( + RenderPlainListSimpleItem, + IPlainListSimpleItem, + original, + render_context, + { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(RenderObject::new(render_context.clone(), obj)?); + } + ret + }; + + Ok(RenderPlainListSimpleItem { + children, + post_blank: original.post_blank, + }) + } +); diff --git a/src/intermediate/element.rs b/src/intermediate/element.rs index 5072ea4..d07534b 100644 --- a/src/intermediate/element.rs +++ b/src/intermediate/element.rs @@ -1,6 +1,7 @@ use super::comment::IComment; use super::keyword::IKeyword; use super::macros::iselector; +use super::IPlainListSimpleItem; use super::IBabelCall; use super::ICenterBlock; @@ -32,6 +33,7 @@ use futures::future::{BoxFuture, FutureExt}; pub(crate) enum IElement { Paragraph(IParagraph), PlainList(IPlainList), + PlainListSimpleItem(IPlainListSimpleItem), CenterBlock(ICenterBlock), QuoteBlock(IQuoteBlock), SpecialBlock(ISpecialBlock), diff --git a/src/intermediate/mod.rs b/src/intermediate/mod.rs index ea61ba1..3516d15 100644 --- a/src/intermediate/mod.rs +++ b/src/intermediate/mod.rs @@ -41,6 +41,7 @@ mod paragraph; mod plain_link; mod plain_list; mod plain_list_item; +mod plain_list_simple_item; mod plain_text; mod planning; mod property_drawer; @@ -108,6 +109,7 @@ pub(crate) use paragraph::IParagraph; pub(crate) use plain_link::IPlainLink; pub(crate) use plain_list::IPlainList; pub(crate) use plain_list_item::IPlainListItem; +pub(crate) use plain_list_simple_item::IPlainListSimpleItem; pub(crate) use plain_text::IPlainText; pub(crate) use planning::IPlanning; pub(crate) use property_drawer::IPropertyDrawer; diff --git a/src/intermediate/plain_list_item.rs b/src/intermediate/plain_list_item.rs index 02f3241..64c7ae1 100644 --- a/src/intermediate/plain_list_item.rs +++ b/src/intermediate/plain_list_item.rs @@ -1,4 +1,5 @@ use super::macros::intermediate; +use super::IPlainListSimpleItem; use super::IElement; use super::IObject; @@ -26,8 +27,19 @@ intermediate!( let children = { let mut ret = Vec::new(); - for elem in original.children.iter() { - ret.push(IElement::new(intermediate_context.clone(), elem).await?); + + // Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted. + if original.children.len() == 1 + && let Some(organic::types::Element::Paragraph(paragraph)) = + original.children.iter().next() + { + ret.push(IElement::PlainListSimpleItem( + IPlainListSimpleItem::new(intermediate_context.clone(), paragraph).await?, + )); + } else { + for elem in original.children.iter() { + ret.push(IElement::new(intermediate_context.clone(), elem).await?); + } } ret }; diff --git a/src/intermediate/plain_list_simple_item.rs b/src/intermediate/plain_list_simple_item.rs new file mode 100644 index 0000000..d247c47 --- /dev/null +++ b/src/intermediate/plain_list_simple_item.rs @@ -0,0 +1,32 @@ +use super::macros::intermediate; +use super::IObject; +use crate::error::CustomError; +use organic::types::StandardProperties; + +/// Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. +#[derive(Debug, Clone)] +pub(crate) struct IPlainListSimpleItem { + pub(crate) children: Vec, + pub(crate) post_blank: organic::types::PostBlank, +} + +intermediate!( + IPlainListSimpleItem, + &'orig organic::types::Paragraph<'parse>, + original, + intermediate_context, + { + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(IObject::new(intermediate_context.clone(), obj).await?); + } + ret + }; + + Ok(IPlainListSimpleItem { + children, + post_blank: original.get_post_blank(), + }) + } +); diff --git a/src/main.rs b/src/main.rs index d2d3edd..71c1ab3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#![feature(let_chains)] use std::process::ExitCode; use clap::Parser; From 27ff13e6755a4b0785c8a9b6e59645d80be083e8 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 17:27:19 -0500 Subject: [PATCH 18/22] Also special-case plain list items containing only paragraphs and sublists. This seems to be the behavior of the upstream org html exporter. --- src/context/plain_list_simple_item.rs | 2 +- src/intermediate/plain_list_item.rs | 27 +++++++++++++++------- src/intermediate/plain_list_simple_item.rs | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/context/plain_list_simple_item.rs b/src/context/plain_list_simple_item.rs index 1b03208..d1cae85 100644 --- a/src/context/plain_list_simple_item.rs +++ b/src/context/plain_list_simple_item.rs @@ -7,7 +7,7 @@ use crate::intermediate::IPlainListSimpleItem; use super::macros::render; use super::RenderObject; -/// Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. +/// Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "plain_list_simple_item")] diff --git a/src/intermediate/plain_list_item.rs b/src/intermediate/plain_list_item.rs index 64c7ae1..9cec4be 100644 --- a/src/intermediate/plain_list_item.rs +++ b/src/intermediate/plain_list_item.rs @@ -28,19 +28,30 @@ intermediate!( let children = { let mut ret = Vec::new(); - // Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted. - if original.children.len() == 1 - && let Some(organic::types::Element::Paragraph(paragraph)) = - original.children.iter().next() - { - ret.push(IElement::PlainListSimpleItem( - IPlainListSimpleItem::new(intermediate_context.clone(), paragraph).await?, - )); + // Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. + let is_simple_list_item = original.children.iter().all(|child| match child { + organic::types::Element::Paragraph(_) | organic::types::Element::PlainList(_) => { + true + } + _ => false, + }); + if is_simple_list_item { + for elem in original.children.iter() { + if let organic::types::Element::Paragraph(paragraph) = elem { + ret.push(IElement::PlainListSimpleItem( + IPlainListSimpleItem::new(intermediate_context.clone(), paragraph) + .await?, + )); + } else { + ret.push(IElement::new(intermediate_context.clone(), elem).await?); + } + } } else { for elem in original.children.iter() { ret.push(IElement::new(intermediate_context.clone(), elem).await?); } } + ret }; diff --git a/src/intermediate/plain_list_simple_item.rs b/src/intermediate/plain_list_simple_item.rs index d247c47..79a7665 100644 --- a/src/intermediate/plain_list_simple_item.rs +++ b/src/intermediate/plain_list_simple_item.rs @@ -3,7 +3,7 @@ use super::IObject; use crate::error::CustomError; use organic::types::StandardProperties; -/// Special case for list items with only 1 child which is a paragraph. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. +/// Special case for list items with only paragraphs and sublists as their children. In those cases, the paragraph tags are omitted. This is equivalent to a Paragraph but in a different struct to have a different type tag. #[derive(Debug, Clone)] pub(crate) struct IPlainListSimpleItem { pub(crate) children: Vec, From bd68681e443c07ce66a2b38fcb98d63a2c43a03a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 17:31:19 -0500 Subject: [PATCH 19/22] Increase the size of headlines. This is to make them stand out more from the regular text. --- default_environment/stylesheet/main.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index a93bd1c..383c8ee 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -107,13 +107,13 @@ body { } h2 { - font-size: 1.8rem; + font-size: 2.3rem; font-weight: 600; } h3 { - font-size: 1.5rem; - font-weight: 500; + font-size: 2.1rem; + font-weight: 600; } .plain_list { @@ -163,7 +163,7 @@ body { } .blog_post_title { - font-size: 2rem; + font-size: 2.5rem; font-weight: 700; padding-bottom: 1rem; } From 01b55b7256d488cf75d69353e06da873fe425648 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 17:44:40 -0500 Subject: [PATCH 20/22] Make paragraphs under footnote definitions display inline. This seems to be the behavior of the upstream org html exporter. --- default_environment/stylesheet/main.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 383c8ee..4db8466 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -153,6 +153,10 @@ body { } .definition { display: inline; + + > p { + display: inline; + } } } } From 4fb08bc7d0862a3dac3824a6f468e452a38ce1d2 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 18:09:43 -0500 Subject: [PATCH 21/22] Wrap inline footnote definitions in a paragraph tag. This is to match the behavior of the upstream org html exporter. --- src/intermediate/paragraph.rs | 13 +++++++++++++ src/intermediate/registry.rs | 13 +++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/intermediate/paragraph.rs b/src/intermediate/paragraph.rs index 0b3adac..8254c2d 100644 --- a/src/intermediate/paragraph.rs +++ b/src/intermediate/paragraph.rs @@ -29,3 +29,16 @@ intermediate!( }) } ); + +impl IParagraph { + pub(crate) async fn artificial<'orig, 'parse>( + _intermediate_context: crate::intermediate::IntermediateContext<'orig, 'parse>, + children: Vec, + post_blank: organic::types::PostBlank, + ) -> Result { + Ok(IParagraph { + children, + post_blank, + }) + } +} diff --git a/src/intermediate/registry.rs b/src/intermediate/registry.rs index 64d1800..f1de21d 100644 --- a/src/intermediate/registry.rs +++ b/src/intermediate/registry.rs @@ -5,6 +5,8 @@ use std::collections::HashMap; use super::ast_node::IAstNode; use super::ast_node::IntoIAstNode; +use super::IObject; +use super::IParagraph; use super::IntermediateContext; type IdCounter = u16; @@ -148,13 +150,20 @@ async fn convert_reference_contents<'orig, 'parse>( intermediate_context: IntermediateContext<'orig, 'parse>, contents: &'orig Vec>, ) -> Result, CustomError> { - let contents = { + let children = { let mut ret = Vec::new(); for obj in contents.iter() { - ret.push(obj.into_ast_node(intermediate_context.clone()).await?); + ret.push(IObject::new(intermediate_context.clone(), obj).await?); } ret }; + let containing_paragraph = + IParagraph::artificial(intermediate_context.clone(), children, 0).await?; + let contents = { + let mut ret = Vec::new(); + ret.push(IAstNode::Paragraph(containing_paragraph)); + ret + }; Ok(contents) } From 7e2fd70212a7f4594b5171c7325abbaef220e520 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Thu, 21 Dec 2023 18:34:42 -0500 Subject: [PATCH 22/22] Style the homepage. --- default_environment/stylesheet/main.css | 38 +++++++++++++------ .../templates/html/blog_stream.dust | 1 + 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/default_environment/stylesheet/main.css b/default_environment/stylesheet/main.css index 4db8466..b648058 100644 --- a/default_environment/stylesheet/main.css +++ b/default_environment/stylesheet/main.css @@ -1,10 +1,11 @@ :root { - --unused-1: #6ccff6; --main-max-width: 800px; --site-background-color: #0a0a0a; --site-text-color: #fffffc; --header-divider-color: #6a687a; + --stream-divider-color: #6ccff6; + --src-font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace; --src-block-background-color: #141414; @@ -54,6 +55,30 @@ body { font-size: 1.2rem; line-height: 1.2; + /* A stand-alone blog post (not in a blog stream). */ + .blog_post { + padding: 1rem 0 3rem 0; + } + + .blog_stream { + .stream_divider { + color: var(--stream-divider-color); + } + } + + /* A blog post in a blog stream (for example, the homepage). */ + .blog_stream_post { + background: #1F1F1F; + padding: 1rem 0.2rem; + } + + .blog_post_title { + font-size: 2.5rem; + font-weight: 700; + padding-bottom: 1rem; + } + + p { margin: 1rem 0; } @@ -160,14 +185,3 @@ body { } } } - -/* A stand-alone blog post (not in a blog stream). */ -.blog_post { - padding: 1rem 0 3rem 0; -} - -.blog_post_title { - font-size: 2.5rem; - font-weight: 700; - padding-bottom: 1rem; -} diff --git a/default_environment/templates/html/blog_stream.dust b/default_environment/templates/html/blog_stream.dust index 97fe63c..694614c 100644 --- a/default_environment/templates/html/blog_stream.dust +++ b/default_environment/templates/html/blog_stream.dust @@ -1,5 +1,6 @@
{#.children} + {@gt key=$idx value=0}
{/gt}
{?.title}{?.self_link}{.title}{:else}
{.title}
{/.self_link}{/.title}