From 96ff207be28274ae59aa67e941c7a6a261ae0c47 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 11 Feb 2016 07:45:21 +0200 Subject: Assign numbers to TOC headings --- cli/context.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cli/context.cxx') diff --git a/cli/context.cxx b/cli/context.cxx index cd5d88c..5b1d387 100644 --- a/cli/context.cxx +++ b/cli/context.cxx @@ -117,6 +117,7 @@ context (ostream& os_, link_regex (data_->link_regex_), id_set (data_->id_set_), ref_set (data_->ref_set_), + heading_map (data_->heading_map_), toc (data_->toc_), tocs (data_->tocs_) { @@ -179,6 +180,7 @@ context (context& c) link_regex (c.link_regex), id_set (c.id_set), ref_set (c.ref_set), + heading_map (c.heading_map), toc (c.toc), tocs (c.tocs) { @@ -1798,6 +1800,11 @@ format (semantics::scope& scope, string const& s, bool para) } } + // Save the heading number for later. + // + if (!n.empty ()) + heading_map[pi] = n; + v += in + "" + n + "" + pv; // No newline tocs.push_back (toc_entry (t)); break; @@ -1915,7 +1922,19 @@ format (semantics::scope& scope, string const& s, bool para) if (!pi.empty ()) v += " id=\"" + pi + '"'; if (!c.empty ()) v += " class=\"" + c + '"'; v += '>'; + + // See if we have a heading number (assigned by TOC). + // + if (!pi.empty ()) + { + heading_map_type::const_iterator i (heading_map.find (pi)); + + if (i != heading_map.end ()) + v += i->second + ' '; + } + v += pv; + v += "'; // @@ This only works for a single string fragment. @@ -2099,6 +2118,7 @@ verify_id_ref () id_set.clear (); ref_set.clear (); + heading_map.clear (); } string context:: -- cgit v1.1