From bf85af04af554fa7e1b0a922796a89098dacfafa Mon Sep 17 00:00:00 2001 From: mandeepsingh2007 Date: Fri, 6 Mar 2026 11:45:33 +0530 Subject: [PATCH 1/2] feat: integrate md4c for markdown parsing --- 3rdparty/s7/s7.h | 2 +- src/Data/Convert/Generic/input.cpp | 3 ++- src/Data/Convert/Markdown/markdown.cpp | 16 ++++++++++++++++ src/Data/Convert/Markdown/markdown.hpp | 13 +++++++++++++ xmake.lua | 2 ++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/Data/Convert/Markdown/markdown.cpp create mode 100644 src/Data/Convert/Markdown/markdown.hpp diff --git a/3rdparty/s7/s7.h b/3rdparty/s7/s7.h index e1b209aa87..8d71e658ff 100644 --- a/3rdparty/s7/s7.h +++ b/3rdparty/s7/s7.h @@ -12,7 +12,7 @@ typedef int64_t s7_int; typedef double s7_double; #ifndef __cplusplus -#ifndef _MSC_VER +#if !defined(_MSC_VER) || (_MSC_VER >= 1800) #include #else #ifndef true diff --git a/src/Data/Convert/Generic/input.cpp b/src/Data/Convert/Generic/input.cpp index b193724beb..03dd13ad5a 100644 --- a/src/Data/Convert/Generic/input.cpp +++ b/src/Data/Convert/Generic/input.cpp @@ -12,6 +12,7 @@ #include "Generic/input.hpp" #include "convert.hpp" #include "converter.hpp" +#include "Markdown/markdown.hpp" #include "file.hpp" #include "hashmap.hpp" #include "image_files.hpp" @@ -310,7 +311,7 @@ void texmacs_input_rep::markdown_flush (bool force) { // ignore: empty buf in markdown is meaningless if (force && !is_empty (buf)) { - write (generic_to_tree (buf, "markdown-snippet")); + write (markdown_to_tree (buf)); buf= ""; } } diff --git a/src/Data/Convert/Markdown/markdown.cpp b/src/Data/Convert/Markdown/markdown.cpp new file mode 100644 index 0000000000..f26da4be17 --- /dev/null +++ b/src/Data/Convert/Markdown/markdown.cpp @@ -0,0 +1,16 @@ +/****************************************************************************** + * MODULE : markdown.cpp + * DESCRIPTION: Markdown to TMU tree conversion (Placeholder) + ******************************************************************************/ + +#include "markdown.hpp" +#include "tree_helper.hpp" +#include "md4c.h" // Testing md4c include + +tree markdown_to_tree(string s) { + // TODO: Phase 2 - Implement md4c AST parsing and mapping to Mogan's tree + // For now, this is a placeholder that returns a basic verbatim tree or text + // just to prove the C++ binding and build works. + + return tree(TUPLE, "document", s); +} diff --git a/src/Data/Convert/Markdown/markdown.hpp b/src/Data/Convert/Markdown/markdown.hpp new file mode 100644 index 0000000000..2299fb7d72 --- /dev/null +++ b/src/Data/Convert/Markdown/markdown.hpp @@ -0,0 +1,13 @@ +/****************************************************************************** + * MODULE : markdown.hpp + * DESCRIPTION: Markdown to TMU tree conversion (Placeholder) + ******************************************************************************/ + +#ifndef MARKDOWN_H +#define MARKDOWN_H + +#include "tree.hpp" + +tree markdown_to_tree(string s); + +#endif // defined MARKDOWN_H diff --git a/xmake.lua b/xmake.lua index 3d1541d0ba..7e5b5bb6fa 100644 --- a/xmake.lua +++ b/xmake.lua @@ -232,6 +232,7 @@ add_requires("freetype "..FREETYPE_VERSION, {system=false, configs={png=true}}) add_requireconfs("liii-pdfhummus.freetype", {version = FREETYPE_VERSION, system = false, configs={png=true}, override=true}) add_requires("argh v1.3.2") +add_requires("md4c") --- package: qt6widgets QT6_VERSION="6.8.3" @@ -638,6 +639,7 @@ target("libmogan") do add_packages("freetype") add_packages("s7") add_packages("argh") + add_packages("md4c") if not is_plat("macosx") then add_packages("libiconv") end From 7af9ac51b17a34d53b6010ec28f5d8de039b273c Mon Sep 17 00:00:00 2001 From: mandeepsingh2007 Date: Fri, 6 Mar 2026 12:32:22 +0530 Subject: [PATCH 2/2] style: fix clang-format space and include sorting issues --- src/Data/Convert/Generic/input.cpp | 2 +- src/Data/Convert/Markdown/markdown.cpp | 10 ++++++---- src/Data/Convert/Markdown/markdown.hpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Data/Convert/Generic/input.cpp b/src/Data/Convert/Generic/input.cpp index 03dd13ad5a..1b59096f81 100644 --- a/src/Data/Convert/Generic/input.cpp +++ b/src/Data/Convert/Generic/input.cpp @@ -12,10 +12,10 @@ #include "Generic/input.hpp" #include "convert.hpp" #include "converter.hpp" -#include "Markdown/markdown.hpp" #include "file.hpp" #include "hashmap.hpp" #include "image_files.hpp" +#include "Markdown/markdown.hpp" #include "moebius/data/scheme.hpp" #include "path.hpp" #include "preferences.hpp" diff --git a/src/Data/Convert/Markdown/markdown.cpp b/src/Data/Convert/Markdown/markdown.cpp index f26da4be17..6af1a6e9df 100644 --- a/src/Data/Convert/Markdown/markdown.cpp +++ b/src/Data/Convert/Markdown/markdown.cpp @@ -4,13 +4,15 @@ ******************************************************************************/ #include "markdown.hpp" -#include "tree_helper.hpp" + #include "md4c.h" // Testing md4c include +#include "tree_helper.hpp" -tree markdown_to_tree(string s) { +tree +markdown_to_tree (string s) { // TODO: Phase 2 - Implement md4c AST parsing and mapping to Mogan's tree // For now, this is a placeholder that returns a basic verbatim tree or text // just to prove the C++ binding and build works. - - return tree(TUPLE, "document", s); + + return tree (TUPLE, "document", s); } diff --git a/src/Data/Convert/Markdown/markdown.hpp b/src/Data/Convert/Markdown/markdown.hpp index 2299fb7d72..757ea8d81c 100644 --- a/src/Data/Convert/Markdown/markdown.hpp +++ b/src/Data/Convert/Markdown/markdown.hpp @@ -8,6 +8,6 @@ #include "tree.hpp" -tree markdown_to_tree(string s); +tree markdown_to_tree (string s); #endif // defined MARKDOWN_H