From 16208f6f3b499103a19b1c3ae61d1cfd71ca102b Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 28 Oct 2025 01:29:52 -0700 Subject: chore: refactor move headers to include folder --- CMakeLists.txt | 11 ++--------- include/markdown_translator.hpp | 39 +++++++++++++++++++++++++++++++++++++++ src/main.cpp | 2 +- src/markdown_translator.cpp | 2 +- src/markdown_translator.h | 39 --------------------------------------- 5 files changed, 43 insertions(+), 50 deletions(-) create mode 100644 include/markdown_translator.hpp delete mode 100644 src/markdown_translator.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c6221e..57da80f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,20 +11,16 @@ else() add_compile_options(-Wall -Wextra -Wpedantic) endif() -# Debug information message(STATUS "Source directory: ${CMAKE_SOURCE_DIR}") message(STATUS "Binary directory: ${CMAKE_BINARY_DIR}") -message(STATUS "Source styles dir: ${CMAKE_SOURCE_DIR}/styles") -message(STATUS "Target styles dir: ${CMAKE_BINARY_DIR}/styles") -# Main executable links to the library add_executable(${PROJECT_NAME} src/main.cpp src/markdown_translator.cpp ) -# target_link_libraries(${PROJECT_NAME} PRIVATE mylib) -# Create a custom target that will always be built +target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include) + add_custom_target(copy_styles ALL COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/styles @@ -33,8 +29,5 @@ add_custom_target(copy_styles ALL VERBATIM ) -# Make sure the styles are copied before the main executable is built add_dependencies(${PROJECT_NAME} copy_styles) - -# Create build/styles directory if it doesn't exist (as a fallback) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/styles) diff --git a/include/markdown_translator.hpp b/include/markdown_translator.hpp new file mode 100644 index 0000000..6c0c1bc --- /dev/null +++ b/include/markdown_translator.hpp @@ -0,0 +1,39 @@ +#ifndef MARKDOWN_TRANSLATOR_H +#define MARKDOWN_TRANSLATOR_H + +#include +#include +#include +#include + +class MarkdownTranslator { +public: + // Constructor + MarkdownTranslator(); + // Destructor + ~MarkdownTranslator(); + // Main translation function - takes markdown content and returns HTML + std::string translate(const std::string& markdownContent, const std::string& cssPath = "styles/carbon.css"); + std::string processLine(const std::string& line); + +private: + // Helper functions for different markdown elements + void processMetadata(const std::vector& lines); + std::string processHeaders(const std::string& line); + std::string processBold(const std::string& text); + std::string processItalic(const std::string& text); + std::string processLinks(const std::string& text); + std::string processParagraph(const std::string& text); + std::string processSingleFigure(const std::string& text); + std::string processFigureBlock(const std::vector& lines); + // Navigation and table of contents + void generateSideBar(std::stringstream& output, const std::vector& headers); + std::string createAnchorId(const std::string& text); + // Utility functions + std::string getCurrentDateTime(); + + // Member variables + std::string title; +}; + +#endif // MARKDOWN_TRANSLATOR_H diff --git a/src/main.cpp b/src/main.cpp index 85433fe..82f16c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "markdown_translator.h" +#include "markdown_translator.hpp" bool parseArguments(int argc, char* argv[], std::unordered_map& params, std::string& inputFile) { if (argc < 2) { diff --git a/src/markdown_translator.cpp b/src/markdown_translator.cpp index 42b8ce5..6cd6bb8 100644 --- a/src/markdown_translator.cpp +++ b/src/markdown_translator.cpp @@ -1,4 +1,4 @@ -#include "markdown_translator.h" +#include "markdown_translator.hpp" #include #include #include diff --git a/src/markdown_translator.h b/src/markdown_translator.h deleted file mode 100644 index 6c0c1bc..0000000 --- a/src/markdown_translator.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MARKDOWN_TRANSLATOR_H -#define MARKDOWN_TRANSLATOR_H - -#include -#include -#include -#include - -class MarkdownTranslator { -public: - // Constructor - MarkdownTranslator(); - // Destructor - ~MarkdownTranslator(); - // Main translation function - takes markdown content and returns HTML - std::string translate(const std::string& markdownContent, const std::string& cssPath = "styles/carbon.css"); - std::string processLine(const std::string& line); - -private: - // Helper functions for different markdown elements - void processMetadata(const std::vector& lines); - std::string processHeaders(const std::string& line); - std::string processBold(const std::string& text); - std::string processItalic(const std::string& text); - std::string processLinks(const std::string& text); - std::string processParagraph(const std::string& text); - std::string processSingleFigure(const std::string& text); - std::string processFigureBlock(const std::vector& lines); - // Navigation and table of contents - void generateSideBar(std::stringstream& output, const std::vector& headers); - std::string createAnchorId(const std::string& text); - // Utility functions - std::string getCurrentDateTime(); - - // Member variables - std::string title; -}; - -#endif // MARKDOWN_TRANSLATOR_H -- cgit v1.2.3