From 2ddff4fbbfbf4593260b96e57e7f975d2d003714 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Sat, 9 Nov 2019 19:35:16 +0100 Subject: Finish substitution implementation --- src/renderer/html.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/renderer/html.rs') diff --git a/src/renderer/html.rs b/src/renderer/html.rs index 421d511..56e3175 100644 --- a/src/renderer/html.rs +++ b/src/renderer/html.rs @@ -9,7 +9,7 @@ use crate::document_tree::{ ExtraAttributes, elements as e, element_categories as c, - // extra_attributes as a, + extra_attributes as a, }; @@ -98,11 +98,33 @@ impl HTMLRender for e::Topic { impl_html_render_cat!(BodyElement { Paragraph, LiteralBlock, DoctestBlock, MathBlock, Rubric, SubstitutionDefinition, Comment, Pending, Target, Raw, Image, Compound, Container, BulletList, EnumeratedList, DefinitionList, FieldList, OptionList, LineBlock, BlockQuote, Admonition, Attention, Hint, Note, Caution, Danger, Error, Important, Tip, Warning, Footnote, Citation, SystemMessage, Figure, Table }); impl_html_render_simple!(Paragraph => p, LiteralBlock => pre, MathBlock => math, Rubric => a, Compound => p, Container => div, BulletList => ul, EnumeratedList => ol, DefinitionList => dl, FieldList => dl, OptionList => pre, LineBlock => div, BlockQuote => blockquote, Admonition => aside, Attention => aside, Hint => aside, Note => aside, Caution => aside, Danger => aside, Error => aside, Important => aside, Tip => aside, Warning => aside, Figure => figure); -impl_html_render_simple_nochildren!(Image => img, Table => table); //TODO: after implementing the table, move it to elems with children +impl_html_render_simple_nochildren!(Table => table); //TODO: after implementing the table, move it to elems with children + +impl HTMLRender for I where I: e::Element + a::ExtraAttributes { + fn render_html(&self, stream: &mut W) -> Result<(), Error> where W: Write { + let extra = self.extra(); + if let Some(ref target) = extra.target { + write!(stream, "", target)?; + } + write!(stream, "\"{}\"", + // TODO: height: Option + // TODO: width: Option + // TODO: scale: Option + write!(stream, ">")?; + if extra.target.is_some() { + write!(stream, "")?; + } + Ok(()) + } +} impl HTMLRender for e::DoctestBlock { fn render_html(&self, _stream: &mut W) -> Result<(), Error> where W: Write { - // + // TODO unimplemented!(); } } @@ -173,7 +195,6 @@ impl HTMLRender for e::SystemMessage { impl_html_render_cat!(TextOrInlineElement { String, Emphasis, Strong, Literal, Reference, FootnoteReference, CitationReference, SubstitutionReference, TitleReference, Abbreviation, Acronym, Superscript, Subscript, Inline, Problematic, Generated, Math, TargetInline, RawInline, ImageInline }); impl_html_render_simple!(Emphasis => em, Strong => strong, Literal => code, FootnoteReference => a, CitationReference => a, TitleReference => a, Abbreviation => abbr, Acronym => acronym, Superscript => sup, Subscript => sub, Inline => span, Math => math, TargetInline => a); -impl_html_render_simple_nochildren!(ImageInline => img); impl HTMLRender for String { fn render_html(&self, stream: &mut W) -> Result<(), Error> where W: Write { @@ -293,8 +314,7 @@ impl HTMLRender for e::Legend { //TODO: render admonitions: Admonition, Attention, Hint, Note, Caution, Danger, Error, Important, Tip, Warning //TODO: properly render tables -//TODO: add reference target: Reference, FootnoteReference, CitationReference, TitleReference +//TODO: add reference target: FootnoteReference, CitationReference, TitleReference //TODO: add title: Abbr, Acronym //TODO: convert math, set display attr //TODO: add id: Rubric, Target, TargetInline -//TODO: add src: Image, ImageInline -- cgit v1.2.3