+
+ // this case is normal.
+ while (!pending_tags_.empty()) {
+ // clear all pending tags up to and including the parsep tag.
+ // note that we work from the back, because we want to get rid
+ // of everything that hasnt' been used.
+ html::StartTag const cur_tag = pending_tags_.back();
+ string const & tag = cur_tag.tag_;
+ tag_stack_.pop_back();
+ if (tag == parsep_tag)
+ break;
+ }
+ return;
+ }
+
+ // this case is also normal, if the parsep tag is the last one
+ // on the stack. otherwise, it's an error.
+ while (!tag_stack_.empty()) {
+ html::StartTag const cur_tag = tag_stack_.back();
+ string const & tag = cur_tag.tag_;
+ tag_stack_.pop_back();
+ if (tag == parsep_tag)
+ break;
+ writeError("Tag `" + tag + "' still open at end of paragraph. Closing.");
+ os_ << cur_tag.asEndTag();