Bashtext text text \cite{arg1, %comment \narg2, % comment \n...% comment} text text text % \cite {argN} \n
C++ (Qt)#include <boost/spirit/include/qi.hpp>#include <boost/spirit/include/phoenix.hpp> #include <string>#include <functional>#include <algorithm> template <class Container>bool add_unique_key(const std::string & key, Container & container){ using namespace std::placeholders; if (std::find_if(container.begin(), container.end(), std::bind(std::equal_to<std::string>(), _1, key)) == container.end()) { container.push_back(key); return true; } return false;} template <class ForwardIterator, class Container>bool key_extractor(ForwardIterator & it, ForwardIterator end, Container & container){ using namespace boost::spirit; namespace ph = boost::phoenix; namespace sn = boost::spirit::standard_wide; auto skipper = sn::space | '%' >> *(qi::char_ - (qi::eol | qi::eoi)) >> (qi::eol | qi::eoi); qi::rule<ForwardIterator, std::string(), decltype(skipper)> key, expr; key = +(qi::char_ - qi::char_(",{}%")); expr = qi::lexeme[qi::lit("\\cite")] >> '{' >> key[ ph::bind(&add_unique_key<Container>, qi::_1, ph::ref(container)) ] % ',' >> '}' | qi::char_ ; return qi::phrase_parse(it, end, *expr, skipper) && (it == end);}
C++ (Qt)nocom = qi::lit("\\%");skipper = sn::space | !nocom >> '%' >> *(qi::char_ - (qi::eol | qi::eoi)) >> (qi::eol | qi::eoi);
C++ (Qt)skipper = sn::space | '%' >> *(qi::char_ - (qi::eol | qi::eoi)) >> (qi::eol | qi::eoi);
C++ (Qt)nocom = qi::lit("\\%");skipper = sn::space | ( !nocom | '%' ) >> *(qi::char_ - (qi::eol | qi::eoi)) >> (qi::eol | qi::eoi);