BareGit

Update design.md and enforce camelCase naming in InlineParser

Author: MetroWind <chris.corsair@gmail.com>
Date: Sat Jan 24 13:09:30 2026 -0800
Commit: e4f0b2baf8ad237b74c4b3b2b54cf413a5117e36

Changes

diff --git a/design.md b/design.md
index c91da2c..1e3b9f1 100644
--- a/design.md
+++ b/design.md
@@ -109,6 +109,21 @@ struct Block {
     *   **Properties**: Use `uni::is_space` and `uni::is_punct` (or equivalent category checks) to comply with CommonMark's definitions of whitespace and punctuation.
     *   **Optimization**: Byte-by-byte scanning will still be used for performance when looking for ASCII-only delimiters (`%`, `{`, `}`, `[`, `]`).
 
+### 3.4 Custom Markup Definitions
+Users can define custom markups that are transformed into macros during the inline parsing phase.
+
+```cpp
+struct PrefixMarkup {
+    std::string prefix;      // The trigger character(s)
+    std::string macro_name;  // Target macro to transform into
+};
+
+struct DelimitedMarkup {
+    std::string delimiter;   // The character used for start and end
+    std::string macro_name;  // Target macro to transform into
+};
+```
+
 ## 4. Component Design
 
 ### 4.0 Top-level Interface (`MacroDown`)
diff --git a/src/parser.cpp b/src/parser.cpp
index 8dcdc08..54a4b97 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -56,18 +56,18 @@ public:
     {
         while (pos_ < input32_.length())
         {
-            if (handle_escape()) continue;
-            if (handle_prefix_markup()) continue;
-            if (handle_delimited_markup()) continue;
-            if (handle_macro()) continue;
-            if (handle_code()) continue;
-            if (handle_link()) continue;
-            if (handle_emphasis()) continue;
+            if (handleEscape()) continue;
+            if (handlePrefixMarkup()) continue;
+            if (handleDelimitedMarkup()) continue;
+            if (handleMacro()) continue;
+            if (handleCode()) continue;
+            if (handleLink()) continue;
+            if (handleEmphasis()) continue;
 
             current_text_ += input32_[pos_];
             pos_++;
         }
-        flush_text();
+        flushText();
         return std::move(nodes_);
     }
 
@@ -84,18 +84,18 @@ private:
     std::u32string current_text_;
 
     // Pushes accumulated plain text into the node list as a Text node.
-    void flush_text()
+    void flushText()
     {
         if (!current_text_.empty())
         {
-            nodes_.push_back(std::make_unique<Node>(Text{una::utf32to8(current_text_)}));
+            nodes_.push_back(std::make_unique<Node>(Text{una::utf32to8(current_text_)} ));
             current_text_.clear();
         }
     }
 
     // Handles backslash escapes. Consumes the backslash and appends the
     // following character literally to the text buffer.
-    bool handle_escape()
+    bool handleEscape()
     {
         if (input32_[pos_] == '\\' && pos_ + 1 < input32_.length())
         {
@@ -109,7 +109,7 @@ private:
     // Handles user-defined prefix markups (e.g., #tag).
     // Matches a specific prefix character and captures text until a boundary
     // (whitespace or punctuation, excluding underscore).
-    bool handle_prefix_markup()
+    bool handlePrefixMarkup()
     {
         for (const auto& info : p_infos_)
         {
@@ -126,7 +126,7 @@ private:
 
                 if (j > pos_ + 1)
                 {
-                    flush_text();
+                    flushText();
                     std::u32string content = input32_.substr(pos_ + 1, j - (pos_ + 1));
                     Macro macro;
                     macro.name = info.macro;
@@ -145,7 +145,7 @@ private:
     // Handles user-defined delimited markups (e.g., :highlight:).
     // Matches a delimiter character and searches for a closing delimiter.
     // Enforces strict rules: no whitespace inside, no punctuation boundaries.
-    bool handle_delimited_markup()
+    bool handleDelimitedMarkup()
     {
         for (const auto& info : d_infos_)
         {
@@ -177,7 +177,7 @@ private:
 
                 if (found_end && valid && j > pos_ + 1)
                 {
-                    flush_text();
+                    flushText();
                     std::u32string content = input32_.substr(pos_ + 1, j - (pos_ + 1));
                     Macro macro;
                     macro.name = info.macro;
@@ -195,11 +195,11 @@ private:
 
     // Handles standard macro calls (e.g., %name{arg}).
     // Parses the macro name and recursively parses its arguments enclosed in {} or [].
-    bool handle_macro()
+    bool handleMacro()
     {
         if (input32_[pos_] == '%')
         {
-            flush_text();
+            flushText();
             pos_++; // skip %
             size_t name_start = pos_;
             while (pos_ < input32_.length() && (una::codepoint::is_alphanumeric(input32_[pos_]) || input32_[pos_] == '_'))
@@ -268,7 +268,7 @@ private:
     }
 
     // Handles inline code blocks enclosed in backticks (`code`).
-    bool handle_code()
+    bool handleCode()
     {
         if (input32_[pos_] == '`')
         {
@@ -276,7 +276,7 @@ private:
             size_t end = input32_.find('`', start);
             if (end != std::u32string::npos)
             {
-                flush_text();
+                flushText();
                 std::u32string content32 = input32_.substr(start, end - start);
 
                 Macro macro;
@@ -296,7 +296,7 @@ private:
 
     // Handles Markdown links ([text](url)).
     // Recursively parses the link text.
-    bool handle_link()
+    bool handleLink()
     {
         if (input32_[pos_] == '[')
         {
@@ -319,7 +319,7 @@ private:
                     size_t url_end = input32_.find(')', url_start);
                     if (url_end != std::u32string::npos)
                     {
-                        flush_text();
+                        flushText();
                         std::u32string label32 = input32_.substr(label_start, close_bracket - label_start);
                         std::u32string url32 = input32_.substr(url_start, url_end - url_start);
 
@@ -349,7 +349,7 @@ private:
 
     // Handles emphasis (*em*) and strong emphasis (**strong**).
     // Recursively parses the content.
-    bool handle_emphasis()
+    bool handleEmphasis()
     {
         if (input32_[pos_] == '*')
         {
@@ -361,7 +361,7 @@ private:
 
             if (end != std::u32string::npos)
             {
-                flush_text();
+                flushText();
                 std::u32string content32 = input32_.substr(start_content, end - start_content);
 
                 Macro macro;
@@ -392,4 +392,4 @@ std::vector<std::unique_ptr<Node>> Parser::parse(
     return parser.parse();
 }
 
-} // namespace macrodown
+} // namespace macrodown
\ No newline at end of file