fn start_tag(&mut self, tag: Tag<'a>) -> io::Result<()> {
        match tag {
            Tag::Paragraph => {
                if self.end_newline {
                    self.write("")
                } else {
                    self.write(" ")
                }
            }
            Tag::Rule => Ok(()),
            Tag::Header(_level) => {
                // Slack doesn't support headers, so just make bold.
                if self.end_newline {
                    self.end_newline = false;
                    self.write("*")
                } else {
                    self.write("\n*")
                }
            }
            Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => {
                // TODO(Jonathon): Throw error to say this feature is unhandled
                Ok(())
            }
            Tag::BlockQuote => {
                if self.end_newline {
                    self.write(">")
                } else {
                    self.write("\n>")
                }
            }
            Tag::CodeBlock(_info) => {
                if !self.end_newline {
                    self.write_newline()?;
                }
                self.write("```")
            }
            Tag::List(Some(1)) => {
                self.list_indent_lvl += 1;
                self.curr_ordered_list_item_num += 1;
                Ok(())
            }
            Tag::List(Some(start)) => {
                self.curr_ordered_list_item_num = start;
                Ok(())
            }
            Tag::List(None) => {
                self.list_indent_lvl += 1;
                if self.end_newline {
                    self.write("")
                } else {
                    self.write("\n")
                }
            }
            Tag::Item => {
                let tabs = "    ".repeat(self.list_indent_lvl - 1);
                self.write(&tabs).unwrap();
                if self.curr_ordered_list_item_num > 0 {
                    self.write(&format!("{}. ", self.curr_ordered_list_item_num))
                } else {
                    self.write("• ")
                }
            }
            Tag::Emphasis => self.write("_"),
            Tag::Strong => self.write("*"),
            Tag::Strikethrough => self.write("~"),
            Tag::Link(_link_type, _dest, _title) => {
                // Don't write anything. We only want to write the hyperlink's text,
                // not the link itself.
                Ok(())
            }
            Tag::Image(_link_type, dest, title) => {
                self.write("<img src=\"")?;
                escape_href(&mut self.writer, &dest)?;
                self.write("\" alt=\"")?;
                self.raw_text()?;
                if !title.is_empty() {
                    self.write("\" title=\"")?;
                    self.write(&title)?;
                }
                self.write("\" />")
            }
            Tag::FootnoteDefinition(name) => {
                // TODO(Jonathon): Decide how to handle these
                if self.end_newline {
                    self.write("<div class=\"footnote-definition\" id=\"")?;
                } else {
                    self.write("\n<div class=\"footnote-definition\" id=\"")?;
                }
                self.write(&*name)?;
                self.write("\"><sup class=\"footnote-definition-label\">")?;
                let len = self.numbers.len() + 1;
                let number = *self.numbers.entry(name).or_insert(len);
                write!(&mut self.writer, "{}", number)?;
                self.write("</sup>")
            }
            Tag::HtmlBlock => Ok(()),
        }
    }
/// Writes the start of an HTML tag.
Writes the start of an HTML tag.
Writes the start of an HTML tag .
fn start_tag(&mut self, tag: Tag<'a>) -> io::Result<()> {
        match tag {
            Tag::Paragraph => {
                if self.end_newline {
                    self.write("")
                } else {
                    self.write(" ")
                }
            }
            Tag::Rule => Ok(()),
            Tag::Header(_level) => {
                // Slack doesn't support headers, so just make bold.
                if self.end_newline {
                    self.end_newline = false;
                    self.write("*")
                } else {
                    self.write("\n*")
                }
            }
            Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => {
                // TODO(Jonathon): Throw error to say this feature is unhandled
                Ok(())
            }
            Tag::BlockQuote => {
                if self.end_newline {
                    self.write(">")
                } else {
                    self.write("\n>")
                }
            }
            Tag::CodeBlock(_info) => {
                if !self.end_newline {
                    self.write_newline()?;
                }
                self.write("```")
            }
            Tag::List(Some(1)) => {
                self.list_indent_lvl += 1;
                self.curr_ordered_list_item_num += 1;
                Ok(())
            }
            Tag::List(Some(start)) => {
                self.curr_ordered_list_item_num = start;
                Ok(())
            }
            Tag::List(None) => {
                self.list_indent_lvl += 1;
                if self.end_newline {
                    self.write("")
                } else {
                    self.write("\n")
                }
            }
            Tag::Item => {
                let tabs = "    ".repeat(self.list_indent_lvl - 1);
                self.write(&tabs).unwrap();
                if self.curr_ordered_list_item_num > 0 {
                    self.write(&format!("{}. ", self.curr_ordered_list_item_num))
                } else {
                    self.write("• ")
                }
            }
            Tag::Emphasis => self.write("_"),
            Tag::Strong => self.write("*"),
            Tag::Strikethrough => self.write("~"),
            Tag::Link(_link_type, _dest, _title) => {
                // Don't write anything. We only want to write the hyperlink's text,
                // not the link itself.
                Ok(())
            }
            Tag::Image(_link_type, dest, title) => {
                self.write("<img src=\"")?;
                escape_href(&mut self.writer, &dest)?;
                self.write("\" alt=\"")?;
                self.raw_text()?;
                if !title.is_empty() {
                    self.write("\" title=\"")?;
                    self.write(&title)?;
                }
                self.write("\" />")
            }
            Tag::FootnoteDefinition(name) => {
                // TODO(Jonathon): Decide how to handle these
                if self.end_newline {
                    self.write("<div class=\"footnote-definition\" id=\"")?;
                } else {
                    self.write("\n<div class=\"footnote-definition\" id=\"")?;
                }
                self.write(&*name)?;
                self.write("\"><sup class=\"footnote-definition-label\">")?;
                let len = self.numbers.len() + 1;
                let number = *self.numbers.entry(name).or_insert(len);
                write!(&mut self.writer, "{}", number)?;
                self.write("</sup>")
            }
            Tag::HtmlBlock => Ok(()),
        }
    }
fn start_tag ( & mut self , tag : Tag < ' a > ) -> io :: Result < ( ) > { match tag { Tag :: Paragraph => { if self . end_newline { self . write ( " " ) } else { self . write ( " " ) } } Tag :: Rule => Ok ( ( ) ) , Tag :: Header ( _level ) => { // Slack doesn't support headers, so just make bold. if self . end_newline { self . end_newline = false ; self . write ( " " ) } else { self . write ( " \n " ) } } Tag :: Table ( _ ) | Tag :: TableHead | Tag :: TableRow | Tag :: TableCell => { // TODO(Jonathon): Throw error to say this feature is unhandled Ok ( ( ) ) } Tag :: BlockQuote => { if self . end_newline { self . write ( " " ) } else { self . write ( " \n " ) } } Tag :: CodeBlock ( _info ) => { if ! self . end_newline { self . write_newline ( ) ? ; } self . write ( " " ) } Tag :: List ( Some ( 1 ) ) => { self . list_indent_lvl += 1 ; self . curr_ordered_list_item_num += 1 ; Ok ( ( ) ) } Tag :: List ( Some ( start ) ) => { self . curr_ordered_list_item_num = start ; Ok ( ( ) ) } Tag :: List ( None ) => { self . list_indent_lvl += 1 ; if self . end_newline { self . write ( " " ) } else { self . write ( " \n " ) } } Tag :: Item => { let tabs = " " . repeat ( self . list_indent_lvl - 1 ) ; self . write ( & tabs ) . unwrap ( ) ; if self . curr_ordered_list_item_num > 0 { self . write ( & format ! ( " " self curr_ordered_list_item_num ) ) } else { self . write ( " } } Tag :: Emphasis => self . write ( " " ) , Tag :: Strong => self . write ( " " ) , Tag :: Strikethrough => self . write ( " " ) , Tag :: Link ( _link_type , _dest , _title ) => { // Don't write anything. We only want to write the hyperlink's text, // not the link itself. Ok ( ( ) ) } Tag :: Image ( _link_type , dest , title ) => { self . write ( " \" " ) ? ; escape_href ( & mut self . writer , & dest ) ? ; self . write ( " \" \" " ) ? ; self . raw_text ( ) ? ; if ! title . is_empty ( ) { self . write ( " \" \" " ) ? ; self . write ( & title ) ? ; } self . write ( " \" " ) } Tag :: FootnoteDefinition ( name ) => { // TODO(Jonathon): Decide how to handle these if self . end_newline { self . write ( " \" \" \" " ) ? ; } else { self . write ( " \n \" \" \" " ) ? ; } self . write ( & * name ) ? ; self . write ( " \" \" \" " ) ? ; let len = self . numbers . len ( ) + 1 ; let number = * self . numbers . entry ( name ) . or_insert ( len ) ; write ! ( mut self writer " " number ) ? ; self . write ( " " ) } Tag :: HtmlBlock => Ok ( ( ) ) , } }
Writes the start of an HTML tag.
Writes the start of an HTML tag .
&mut self
tag
Tag<'a>
&mut self
tag
Tag<'a>