@@ -328,6 +328,28 @@ bool Reformat::Cell::parse_keyformat(const std::string& key,
328328
329329 return true ;
330330 }
331+ else if (key == " prefix" )
332+ {
333+ std::string value;
334+
335+ if (!parse_keyvalue (curr, end, value))
336+ value = " " ;
337+
338+ m_prefix = value;
339+
340+ return true ;
341+ }
342+ else if (key == " suffix" )
343+ {
344+ std::string value;
345+
346+ if (!parse_keyvalue (curr, end, value))
347+ value = " " ;
348+
349+ m_suffix = value;
350+
351+ return true ;
352+ }
331353 else
332354 {
333355 OUT_THROW (" Invalid cell-level key: " << key);
@@ -356,6 +378,12 @@ void Reformat::Cell::apply(const Cell& c)
356378
357379 if (c.m_grouping .size ())
358380 m_grouping = c.m_grouping ;
381+
382+ if (c.m_prefix .size ())
383+ m_prefix = c.m_prefix ;
384+
385+ if (c.m_suffix .size ())
386+ m_suffix = c.m_suffix ;
359387}
360388
361389// ! Test if we need to read the row/column data
@@ -728,6 +756,14 @@ std::string Reformat::format(int row, int col, const std::string& in_text) const
728756
729757 text = replace_all (text, " ," , fmt.m_grouping );
730758
759+ // *** add prefix and suffix ***
760+
761+ if (fmt.m_prefix .size ())
762+ text = fmt.m_prefix + text;
763+
764+ if (fmt.m_suffix .size ())
765+ text = text + fmt.m_suffix ;
766+
731767 // *** check for row/column minimum or maximum formatting ***
732768
733769 DBG (" fmt: " << in_text << " - " << fmt.m_min_text );
@@ -761,11 +797,18 @@ std::string Reformat::format(int row, int col, const std::string& in_text) const
761797 fmt.apply (colfmt->second );
762798 }
763799
800+ // *** escape special LaTeX characters ***
801+
764802 if (fmt.m_escape )
765- {
766- // escape special LaTeX characters
767803 text = escape_latex (text);
768- }
804+
805+ // *** add prefix and suffix ***
806+
807+ if (fmt.m_prefix .size ())
808+ text = fmt.m_prefix + text;
809+
810+ if (fmt.m_suffix .size ())
811+ text = text + fmt.m_suffix ;
769812 }
770813
771814 return text;
0 commit comments