Skip to content

Commit 04edac3

Browse files
author
Michael Axtmann
committed
Remove tabsep code.
1 parent 0b153f4 commit 04edac3

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

src/latex.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,54 @@ void SpLatex::tabular(
475475
}
476476
}
477477

478+
//! Process % DEFMACRO commands
479+
void SpLatex::defmacro(size_t ln, size_t indent, const std::string& cmdline)
480+
{
481+
std::string query = cmdline;
482+
483+
// find REFORMAT, parse format and remove clause from query
484+
Reformat reformat;
485+
reformat.parse_query(query);
486+
487+
// execute query
488+
SqlQuery sql = g_db->query(query);
489+
490+
sql->read_complete();
491+
492+
// prepare reformatting
493+
reformat.prepare(sql);
494+
495+
std::ostringstream oss;
496+
for (unsigned int row = 0; row < sql->num_rows(); ++row)
497+
{
498+
for (unsigned int col = 0; col < sql->num_cols(); ++col)
499+
{
500+
if (col != 0) oss << std::endl;
501+
oss << "\\def\\"
502+
<< str_reduce(sql->col_name(col))
503+
<< "{"
504+
<< reformat.format(0, col, sql->text(0, col))
505+
<< "}";
506+
}
507+
}
508+
509+
std::string output = oss.str();
510+
511+
// scan lines forward and gobble all lines containing \def commands
512+
static const boost::regex
513+
re_defmacro("[[:blank:]]*\\\\def\\\\[^{]+\\{[^}]+\\}.*");
514+
boost::smatch rm;
515+
516+
size_t eln = ln;
517+
while (eln < m_lines.size() &&
518+
boost::regex_match(m_lines[eln], rm, re_defmacro))
519+
{
520+
++eln;
521+
}
522+
523+
m_lines.replace(ln, eln, indent, output, "DEFMACRO");
524+
}
525+
478526
//! process line-based file in place
479527
SpLatex::SpLatex(TextLines& lines)
480528
: m_lines(lines)

0 commit comments

Comments
 (0)