Mercurial > thymian
comparison 3rdparty/maddy/breaklineparser.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 * BreakLineParser | |
| 22 * | |
| 23 * @class | |
| 24 */ | |
| 25 class BreakLineParser : public LineParser | |
| 26 { | |
| 27 public: | |
| 28 /** | |
| 29 * Parse | |
| 30 * | |
| 31 * From Markdown: `text\r\n text` | |
| 32 * | |
| 33 * To HTML: `text<br> text` | |
| 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(R"((\r\n|\r))"); | |
| 43 static std::string replacement = "<br>"; | |
| 44 | |
| 45 line = std::regex_replace(line, re, replacement); | |
| 46 } | |
| 47 }; // class BreakLineParser | |
| 48 | |
| 49 // ----------------------------------------------------------------------------- | |
| 50 | |
| 51 } // namespace maddy |
