Improve code2html to correctly highlight C++11 features, including new keywords, string literal prefixes, and raw string literals.
Important
The parser has a fundamental bug where it doesn't flush the current word being built when it encounters a string or comment start. This causes prefixes like u8 or characters before a comment to appear after the string/comment. I will fix this as part of the C++11 implementation.
[MODIFY] cpp.kwd
Add C++11 keywords:
alignas,alignof,char16_t,char32_t,constexpr,decltype,noexcept,nullptr,static_assert,thread_local,final,override.
[MODIFY] parser.cpp
- Fix word flushing: Ensure
keyWordis flushed (search for match and output) when enteringstring_literal,char_literal, or comments. - Support String Prefixes: Modify
handle_codeorhandle_literalto handleu8,u,U, andLprefixes correctly. - Support Raw String Literals: Handle
R"(...)"syntax. This is more complex because it uses a custom delimiter.
[MODIFY] parser.h
- Add a helper method
flushKeyWordto avoid duplication. - Potentially update
Contextto handle raw strings.
- Run
./code2html tests/test_cpp11.cpp - Verify the output
tests/test_cpp11.cpp.htmlfor:- Correct keyword highlighting (blue).
- Correct string literal highlighting (gray/original color).
- Correct placement of prefixes (e.g.,
u8"..."should not become"..."u8). - Correct handling of raw strings
R"(...)".