#![allow(unused_variables)] use export::Handler; use headline::Headline; use objects::{Cookie, FnRef, InlineCall, InlineSrc, Link, Macros, RadioTarget, Snippet, Target}; use std::io::{Result, Write}; pub struct HtmlHandler; impl Handler for HtmlHandler { fn handle_start_headline(&mut self, w: &mut W, hdl: Headline) -> Result<()> { write!( w, "{1}", if hdl.level <= 6 { hdl.level } else { 6 }, hdl.title ) } fn handle_end_headline(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_start_section(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_end_section(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_start_paragraph(&mut self, w: &mut W) -> Result<()> { write!(w, "

") } fn handle_end_paragraph(&mut self, w: &mut W) -> Result<()> { write!(w, "

") } fn handle_start_center_block(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_end_center_block(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_start_quote_block(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_end_quote_block(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_start_special_block( &mut self, w: &mut W, name: &str, args: Option<&str>, ) -> Result<()> { write!(w, "
") } fn handle_end_special_block(&mut self, w: &mut W) -> Result<()> { write!(w, "
") } fn handle_comment_block( &mut self, w: &mut W, contents: &str, args: Option<&str>, ) -> Result<()> { Ok(()) } fn handle_example_block( &mut self, w: &mut W, contents: &str, args: Option<&str>, ) -> Result<()> { write!(w, "
{}
", contents) } fn handle_export_block(&mut self, w: &mut W, contents: &str, args: Option<&str>) -> Result<()> { Ok(()) } fn handle_src_block(&mut self, w: &mut W, contents: &str, args: Option<&str>) -> Result<()> { write!(w, "
{}
", contents) } fn handle_verse_block(&mut self, w: &mut W, contents: &str, args: Option<&str>) -> Result<()> { Ok(()) } fn handle_start_dyn_block(&mut self, w: &mut W, name: &str, args: Option<&str>) -> Result<()> { Ok(()) } fn handle_end_dyn_block(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_start_list(&mut self, w: &mut W, is_ordered: bool) -> Result<()> { if is_ordered { write!(w, "
    ") } else { write!(w, "
      ") } } fn handle_end_list(&mut self, w: &mut W, is_ordered: bool) -> Result<()> { if is_ordered { write!(w, "
") } else { write!(w, "") } } fn handle_start_list_item(&mut self, w: &mut W) -> Result<()> { write!(w, "
  • ") } fn handle_end_list_item(&mut self, w: &mut W) -> Result<()> { write!(w, "
  • ") } fn handle_aff_keywords(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_call(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_clock(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_comment(&mut self, w: &mut W, contents: &str) -> Result<()> { Ok(()) } fn handle_table_start(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_table_end(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_table_cell(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_latex_env(&mut self, w: &mut W) -> Result<()> { Ok(()) } fn handle_fn_def(&mut self, w: &mut W, label: &str, contents: &str) -> Result<()> { Ok(()) } fn handle_keyword(&mut self, w: &mut W, key: &str, value: &str) -> Result<()> { Ok(()) } fn handle_rule(&mut self, w: &mut W) -> Result<()> { write!(w, "
    ") } fn handle_cookie(&mut self, w: &mut W, cookie: Cookie) -> Result<()> { Ok(()) } fn handle_fn_ref(&mut self, w: &mut W, fn_ref: FnRef) -> Result<()> { Ok(()) } fn handle_inline_call(&mut self, w: &mut W, inline_call: InlineCall) -> Result<()> { Ok(()) } fn handle_inline_src(&mut self, w: &mut W, inline_src: InlineSrc) -> Result<()> { write!(w, "{}", inline_src.body) } fn handle_link(&mut self, w: &mut W, link: Link) -> Result<()> { write!( w, "{}", link.path, link.desc.unwrap_or(link.path) ) } fn handle_macros(&mut self, w: &mut W, macros: Macros) -> Result<()> { Ok(()) } fn handle_radio_target(&mut self, w: &mut W, target: RadioTarget) -> Result<()> { Ok(()) } fn handle_snippet(&mut self, w: &mut W, snippet: Snippet) -> Result<()> { if snippet.name.eq_ignore_ascii_case("HTML") { write!(w, "{}", snippet.value) } else { Ok(()) } } fn handle_target(&mut self, w: &mut W, target: Target) -> Result<()> { Ok(()) } fn handle_start_bold(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_end_bold(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_start_italic(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_end_italic(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_start_strike(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_end_strike(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_start_underline(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_end_underline(&mut self, w: &mut W) -> Result<()> { write!(w, "") } fn handle_verbatim(&mut self, w: &mut W, contents: &str) -> Result<()> { write!(w, "{}", contents) } fn handle_code(&mut self, w: &mut W, contents: &str) -> Result<()> { write!(w, "{}", contents) } fn handle_text(&mut self, w: &mut W, contents: &str) -> Result<()> { write!(w, "{}", contents.replace('\n', " ")) } }