diff --git a/src/syntax_highlight.hpp b/src/syntax_highlight.hpp
index 3a16c99..a85d603 100644
--- a/src/syntax_highlight.hpp
+++ b/src/syntax_highlight.hpp
@@ -50,7 +50,7 @@ namespace quickbook
| macro
| escape
| preprocessor [Process("preprocessor", self.out)]
- | comment [Process("comment", self.out)]
+ | comment
| keyword [Process("keyword", self.out)]
| identifier [Process("identifier", self.out)]
| special [Process("special", self.out)]
@@ -102,7 +102,29 @@ namespace quickbook
;
comment
- = cl::comment_p("//") | cl::comment_p("/*", "*/")
+ = ( "//"
+ >> *(cl::anychar_p - (cl::eol_p | "``"))
+ ) [Process("comment", self.out)]
+ >> *( escape
+ | (
+ +(cl::anychar_p - (cl::eol_p | "``"))
+ ) [Process("comment", self.out)]
+ )
+ | ( "/*"
+ >> *(cl::anychar_p - (cl::str_p("*/") | "``"))
+ >> ("*/" | cl::end_p)
+ ) [Process("comment", self.out)]
+ | ( "/*"
+ >> *(cl::anychar_p - "``")
+ ) [Process("comment", self.out)]
+ >> *( escape
+ | ( +(cl::anychar_p - (cl::str_p("*/") | "``"))
+ >> cl::eps_p("``")
+ ) [Process("comment", self.out)]
+ )
+ >> !( +(cl::anychar_p - cl::str_p("*/"))
+ >> !cl::str_p("*/")
+ ) [Process("comment", self.out)]
;
keyword
@@ -202,7 +224,7 @@ namespace quickbook
*( (+cl::space_p) [Space(self.out)]
| macro
| escape
- | comment [Process("comment", self.out)]
+ | comment
| keyword [Process("keyword", self.out)]
| identifier [Process("identifier", self.out)]
| special [Process("special", self.out)]
@@ -250,7 +272,9 @@ namespace quickbook
;
comment
- = cl::comment_p("#")
+ = ( "#"
+ >> *(cl::anychar_p - (cl::eol_p | "``"))
+ ) [Process("comment", self.out)]
;
keyword
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index d07e83c..86c8c4d 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -26,6 +26,8 @@ test-suite quickbook.test :
[ quickbook-test code-block-2 ]
[ quickbook-test code-block-3 ]
[ quickbook-test code-block-teletype ]
+ [ quickbook-test code-block-cpp ]
+ [ quickbook-test code-block-python ]
[ quickbook-test code-snippet ]
[ quickbook-test preformatted ]
[ quickbook-test link ]
diff --git a/test/code-block-cpp.gold b/test/code-block-cpp.gold
new file mode 100644
index 0000000..fd943f8
--- /dev/null
+++ b/test/code-block-cpp.gold
@@ -0,0 +1,29 @@
+
+
+
+ C++ Code Blocks
+// No escape
+/* No escape */
+/* No escape
+ * with newlines
+ */
+// In Header: <boost/optional/optional.hpp>
+/* In Header: <boost/optional/optional.hpp> */
+/* Multiple escapes: italic
+ * underlinebold
+ */
+
+
+ A badly formed comment:
+
+
+/* Oh dear
+
+
+ A badly formed comment with an escape:
+
+
+/* Oh dear bold
+
+
diff --git a/test/code-block-cpp.quickbook b/test/code-block-cpp.quickbook
new file mode 100644
index 0000000..be8043a
--- /dev/null
+++ b/test/code-block-cpp.quickbook
@@ -0,0 +1,22 @@
+[article C++ Code Blocks
+[quickbook 1.5]
+]
+
+ // No escape
+ /* No escape */
+ /* No escape
+ * with newlines
+ */
+ // In Header: <``[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]``>
+ /* In Header: <``[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]``> */
+ /* Multiple escapes: ``/italic/``
+ * ``_underline_````*bold*``
+ */
+
+A badly formed comment:
+
+ /* Oh dear
+
+A badly formed comment with an escape:
+
+ /* Oh dear ``*bold*``
diff --git a/test/code-block-python.gold b/test/code-block-python.gold
new file mode 100644
index 0000000..6ab5a04
--- /dev/null
+++ b/test/code-block-python.gold
@@ -0,0 +1,10 @@
+
+
+
+ Python Code Blocks
+# No escape
+# Escape: bold
+# Escape: underlineitalic
+
+
diff --git a/test/code-block-python.quickbook b/test/code-block-python.quickbook
new file mode 100644
index 0000000..45e700e
--- /dev/null
+++ b/test/code-block-python.quickbook
@@ -0,0 +1,8 @@
+[article Python Code Blocks
+[quickbook 1.5]
+[source-mode python]
+]
+
+ # No escape
+ # Escape: ``*bold*``
+ # Escape: ``_underline_````/italic/``
diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold
index c999175..49b2bfa 100644
--- a/test/quickbook-manual.gold
+++ b/test/quickbook-manual.gold
@@ -1549,8 +1549,8 @@ escape (no processing/formatting)
int main()
{
- // Sample code
- std::cout << "Hello, World\n";
+ // Sample code
+ std::cout << "Hello, World\n";
return 0;
}
@@ -2714,8 +2714,8 @@ for the journey to old age.]]]
std::string foo()
{
- // return 'em, foo man!
- return "foo";
+ // return 'em, foo man!
+ return "foo";
}
@@ -2726,8 +2726,8 @@ for the journey to old age.]]]
std::string bar()
{
- // return 'em, bar man!
- return "bar";
+ // return 'em, bar man!
+ return "bar";
}
@@ -2743,10 +2743,10 @@ for the journey to old age.]]]
get marked up. We use distinguishable comments following the form:
-//[id
-some code here
-//]
-
+//[id
+some code here
+//]
+
The first comment line above initiates a named code-snippet. This prefix
will not be visible in quickbook. The entire code-snippet in between
-//` some [*quickbook] markup here
-
+//` some [*quickbook] markup here
+
and: