Skip to content

Commit

Permalink
Merge pull request #1254 from zeitgeist87/CppRaw
Browse files Browse the repository at this point in the history
Add the C++11 raw string feature to the cpp language
  • Loading branch information
zeitgeist87 authored Dec 27, 2017
2 parents 37af500 + d134a3a commit 71595be
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions components/prism-cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ Prism.languages.insertBefore('cpp', 'keyword', {
pattern: /(class\s+)\w+/i,
lookbehind: true
}
});

Prism.languages.insertBefore('cpp', 'string', {
'raw-string': {
pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
alias: 'string',
greedy: true
}
});
2 changes: 1 addition & 1 deletion components/prism-cpp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions tests/languages/cpp/raw_string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
R"raw(
test
)raw"
R"(no delimiter)"
R"(foo)"R"(bar)"

----------------------------------------------------

[
["raw-string", "R\"raw(\r\ntest\r\n)raw\""],
["raw-string", "R\"(no delimiter)\""],
["raw-string", "R\"(foo)\""],
["raw-string", "R\"(bar)\""]
]

----------------------------------------------------

Checks for the C++11 raw string feature

0 comments on commit 71595be

Please sign in to comment.