]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/tools/quickbook/src/syntax_highlight.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / quickbook / src / syntax_highlight.cpp
index 12e2c5e077189cb1f617cdfe9420ea090093baa9..bbdcb5186d34fa10e24c590c28ed4157a37a0222 100644 (file)
@@ -18,7 +18,7 @@
 #include "syntax_highlight.hpp"
 #include "utils.hpp"
 #include "files.hpp"
-#include "native_text.hpp"
+#include "stream.hpp"
 #include "phrase_tags.hpp"
 
 namespace quickbook
@@ -34,12 +34,12 @@ namespace quickbook
 
         // State
         bool support_callouts;
-        boost::string_ref marked_text;
+        quickbook::string_view marked_text;
 
-        syntax_highlight_actions(quickbook::state& state, bool is_block) :
-            state(state),
-            do_macro_impl(state),
-            support_callouts(is_block && (qbk_version_n >= 107u ||
+        syntax_highlight_actions(quickbook::state& state_, bool is_block_) :
+            state(state_),
+            do_macro_impl(state_),
+            support_callouts(is_block_ && (qbk_version_n >= 107u ||
                 state.current_file->is_code_snippets)),
             marked_text()
         {}
@@ -129,7 +129,7 @@ namespace quickbook
     void syntax_highlight_actions::mark_text(parse_iterator first,
             parse_iterator last)
     {
-        marked_text = boost::string_ref(first.base(), last.base() - first.base());
+        marked_text = quickbook::string_view(first.base(), last.base() - first.base());
     }
 
     void syntax_highlight_actions::callout(parse_iterator, parse_iterator)
@@ -192,8 +192,8 @@ namespace quickbook
     // Grammar for C++ highlighting
     struct cpp_highlight : public cl::grammar<cpp_highlight>
     {
-        cpp_highlight(syntax_highlight_actions& actions)
-            : actions(actions) {}
+        explicit cpp_highlight(syntax_highlight_actions& actions_)
+            : actions(actions_) {}
 
         template <typename Scanner>
         struct definition
@@ -362,8 +362,8 @@ namespace quickbook
     // http://docs.python.org/ref/ref.html
     struct python_highlight : public cl::grammar<python_highlight>
     {
-        python_highlight(syntax_highlight_actions& actions)
-            : actions(actions) {}
+        explicit python_highlight(syntax_highlight_actions& actions_)
+            : actions(actions_) {}
 
         template <typename Scanner>
         struct definition
@@ -390,7 +390,11 @@ namespace quickbook
                     =
                     *(  (+cl::space_p)                  [plain_char]
                     |   macro
-                    |   escape          
+                    |   escape
+                    |   cl::eps_p(ph::var(self.actions.support_callouts))
+                    >>  (   line_callout                [callout]
+                        |   inline_callout              [callout]
+                        )
                     |   comment
                     |   keyword                         [span("keyword")]
                     |   identifier                      [span("identifier")]
@@ -428,6 +432,19 @@ namespace quickbook
                     )                                   [post_escape_back]
                     ;
 
+                inline_callout
+                    =   "#<" >> *cl::space_p >>
+                        (*(cl::anychar_p - cl::eol_p))  [mark_text]
+                    ;
+
+                line_callout
+                    =   cl::confix_p(
+                            "#<<" >> *cl::space_p,
+                            (*cl::anychar_p)            [mark_text],
+                            (cl::eol_p | cl::end_p)
+                        )
+                    ;
+
                 comment
                     =   cl::str_p("#")                  [span_start("comment")]
                     >>  *(  escape
@@ -482,7 +499,8 @@ namespace quickbook
             }
 
             cl::rule<Scanner>
-                            program, macro, comment, special, string_, string_prefix, 
+                            program, macro, inline_callout, line_callout,
+                            comment, special, string_, string_prefix,
                             short_string, long_string, number, identifier, keyword, 
                             escape, string_char;
 
@@ -498,8 +516,8 @@ namespace quickbook
     // Grammar for plain text (no actual highlighting)
     struct teletype_highlight : public cl::grammar<teletype_highlight>
     {
-        teletype_highlight(syntax_highlight_actions& actions)
-            : actions(actions) {}
+        teletype_highlight(syntax_highlight_actions& actions_)
+            : actions(actions_) {}
 
         template <typename Scanner>
         struct definition