summaryrefslogtreecommitdiff
path: root/transpiler/replacer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'transpiler/replacer.cpp')
-rw-r--r--transpiler/replacer.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/transpiler/replacer.cpp b/transpiler/replacer.cpp
index 28c2e8e..0225f92 100644
--- a/transpiler/replacer.cpp
+++ b/transpiler/replacer.cpp
@@ -17,6 +17,8 @@ const char* types[] = {
"struct", "class"
};
+const char* commentType = "//";
+
bool isType(char* str, int size) {
if (size == 0) {
return false;
@@ -84,7 +86,16 @@ std::string insertCodeSnippets(char* workingDirectory, char* bodyContent) {
}
int tokenLength = (tokenEnd - tokenStart);
- if (isType(&snippetContent[tokenStart], tokenLength)) {
+
+ if (tokenLength == strlen(commentType) && strncmp(&snippetContent[tokenStart], commentType, tokenLength) == 0) {
+ // @NOTE: Assuming comments are always on a single line
+ s.append("<span class=\"code_comment\">");
+ while (snippetContent[tokenEnd] != '\n') {
+ tokenEnd++;
+ }
+ s.append(&snippetContent[tokenStart], tokenEnd - tokenStart);
+ s.append("</span>");
+ } else if (isType(&snippetContent[tokenStart], tokenLength)) {
s.append("<span class=\"code_keyword\">");
s.append(&snippetContent[tokenStart], tokenLength);
s.append("</span>");