comparison 3rdparty/maddy/inlinecodeparser.h @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
1 /*
2 * This project is licensed under the MIT license. For more information see the
3 * LICENSE file.
4 */
5 #pragma once
6
7 // -----------------------------------------------------------------------------
8
9 #include <string>
10 #include <regex>
11
12 #include "maddy/lineparser.h"
13
14 // -----------------------------------------------------------------------------
15
16 namespace maddy {
17
18 // -----------------------------------------------------------------------------
19
20 /**
21 * InlineCodeParser
22 *
23 * @class
24 */
25 class InlineCodeParser : public LineParser
26 {
27 public:
28 /**
29 * Parse
30 *
31 * From Markdown: `text `some code``
32 *
33 * To HTML: `text <code>some code</code>`
34 *
35 * @method
36 * @param {std::string&} line The line to interpret
37 * @return {void}
38 */
39 void
40 Parse(std::string& line) override
41 {
42 static std::regex re("`([^`]*)`");
43 static std::string replacement = "<code>$1</code>";
44
45 line = std::regex_replace(line, re, replacement);
46 }
47 }; // class InlineCodeParser
48
49 // -----------------------------------------------------------------------------
50
51 } // namespace maddy