From 8b7fe82727bb5453269f4126aa7824433eaefe82 Mon Sep 17 00:00:00 2001 From: Eliott Paris Date: Sat, 6 Jul 2019 10:39:23 +0200 Subject: [PATCH] Add support for other than c++ languages in code blocks --- include/otdgen/DocCodeBlock.h | 8 +------- src/GeneratorGitHubMarkDown.cpp | 15 ++++----------- src/GeneratorPlainText.cpp | 14 ++++++-------- src/StructuralAnalyser.cpp | 7 ++----- 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/include/otdgen/DocCodeBlock.h b/include/otdgen/DocCodeBlock.h index acfd704..aadca57 100755 --- a/include/otdgen/DocCodeBlock.h +++ b/include/otdgen/DocCodeBlock.h @@ -31,12 +31,6 @@ class DocCodeBlock public: - enum class Type - { - None, - Cpp, - }; - enum class LineType { Normal, @@ -52,7 +46,7 @@ class DocCodeBlock DocCodeBlock & operator = (const DocCodeBlock & rhs) = default; DocCodeBlock & operator = (DocCodeBlock && rhs) = default; - Type type; + std::string type; std::list > lines; diff --git a/src/GeneratorGitHubMarkDown.cpp b/src/GeneratorGitHubMarkDown.cpp index b2f29d6..d39a2f7 100755 --- a/src/GeneratorGitHubMarkDown.cpp +++ b/src/GeneratorGitHubMarkDown.cpp @@ -357,17 +357,10 @@ Name : process void GeneratorGitHubMarkDown::process (std::string & output, std::vector & /* cur */, const DocCodeBlock & codeblock) { - switch (codeblock.type) - { - case DocCodeBlock::Type::None: - output += "```\n"; - break; - - case DocCodeBlock::Type::Cpp: - output += "```c++\n"; - break; - } - + output += "```"; + output += codeblock.type; + output += "\n"; + for (auto && line : codeblock.lines) { output += line.first + "\n"; diff --git a/src/GeneratorPlainText.cpp b/src/GeneratorPlainText.cpp index 1b0256e..aab7c75 100755 --- a/src/GeneratorPlainText.cpp +++ b/src/GeneratorPlainText.cpp @@ -322,17 +322,15 @@ void GeneratorPlainText::process (std::string & output, std::vector _content.end (), std::make_shared () )); - block.type = DocCodeBlock::Type::None; + block.type = ""; auto it = codeblock.options.find ("language"); if (it != codeblock.options.end ()) { - if (it->second == "c++") - { - block.type = DocCodeBlock::Type::Cpp; - } + block.type = it->second; } for (auto && line : codeblock.lines)