mirror of
https://github.com/boostorg/quickbook.git
synced 2026-01-27 07:02:15 +00:00
37 lines
920 B
C++
37 lines
920 B
C++
#include "syntax_highlight.hpp"
|
|
#include "actions_class.hpp"
|
|
|
|
namespace quickbook
|
|
{
|
|
std::string syntax_highlight::operator()(iterator first, iterator last) const
|
|
{
|
|
escape_actions.phrase.push();
|
|
|
|
// print the code with syntax coloring
|
|
if (source_mode == "c++")
|
|
{
|
|
cpp_highlight cpp_p(escape_actions);
|
|
parse(first, last, cpp_p);
|
|
}
|
|
else if (source_mode == "python")
|
|
{
|
|
python_highlight python_p(escape_actions);
|
|
parse(first, last, python_p);
|
|
}
|
|
else if (source_mode == "teletype")
|
|
{
|
|
teletype_highlight teletype_p(escape_actions);
|
|
parse(first, last, teletype_p);
|
|
}
|
|
else
|
|
{
|
|
BOOST_ASSERT(0);
|
|
}
|
|
|
|
std::string str;
|
|
escape_actions.phrase.swap(str);
|
|
escape_actions.phrase.pop();
|
|
|
|
return str;
|
|
}
|
|
} |