Makefile.fetch                        |    1 
 RepositoryExternal.mk                 |   17 ++++++++++
 bin/oss-fuzz-setup.sh                 |    1 
 config_host.mk.in                     |    3 +
 configure.ac                          |   56 ++++++++++++++++++++++++++++++++++
 download.lst                          |    5 +++
 external/Module_external.mk           |    1 
 external/md4c/Makefile                |    7 ++++
 external/md4c/Module_md4c.mk          |   14 ++++++++
 external/md4c/README                  |    1 
 external/md4c/StaticLibrary_md4c.mk   |   29 +++++++++++++++++
 external/md4c/UnpackedTarball_md4c.mk |   13 +++++++
 readlicense_oo/license/license.xml    |   22 +++++++++++++
 13 files changed, 170 insertions(+)

New commits:
commit 8539f39c84fce346fe334b62b7b7fe3bd60d9287
Author:     Ujjawal Kumar <[email protected]>
AuthorDate: Fri Jun 13 23:07:17 2025 +0530
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Sun Jun 22 14:03:08 2025 +0200

    Add MD4C common mark import library
    
    MD4C is Markdown parser implementation in C, compliant with the
    CommonMark specification v0.31
    
    Change-Id: Id0ab4d60d9ba9815feb954705d767022fffd5d08
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183850
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/Makefile.fetch b/Makefile.fetch
index 332a73fb5d2c..f9b9339b9df7 100644
--- a/Makefile.fetch
+++ b/Makefile.fetch
@@ -171,6 +171,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk 
$(SRCDIR)/download.lst $(S
                $(call fetch_Optional,LPSOLVE,LPSOLVE_TARBALL) \
                $(call fetch_Optional,LXML,LXML_TARBALL) \
                $(call 
fetch_Optional,MARIADB_CONNECTOR_C,MARIADB_CONNECTOR_C_TARBALL) \
+               $(call fetch_Optional,MD4C,MD4C_TARBALL) \
                $(call fetch_Optional,MDDS,MDDS_TARBALL) \
                $(call fetch_Optional,ZXCVBN,ZXCVBN_C_TARBALL) \
                $(call fetch_Optional,ZXING,ZXING_TARBALL) \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 757a38162190..601274d9b15e 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -416,6 +416,23 @@ else
   endef
 endif
 
+ifneq ($(SYSTEM_MD4C),)
+  define gb_LinkTarget__use_md4c
+    $(call gb_LinkTarget_add_libs,$(1),$(MD4C_LIBS))
+  endef
+
+  gb_ExternalProject__use_md4c :=
+else
+  define gb_LinkTarget__use_md4c
+    $(call gb_LinkTarget_set_include,$(1),$(MD4C_CFLAGS) $$(INCLUDE))
+    $(call gb_LinkTarget_use_static_libraries,$(1),md4c)
+  endef
+
+  define gb_ExternalProject__use_md4c
+    $(call gb_ExternalProject_use_static_libraries,$(1),md4c)
+  endef
+endif
+
 
 ifneq ($(SYSTEM_LIBJPEG),)
 
diff --git a/bin/oss-fuzz-setup.sh b/bin/oss-fuzz-setup.sh
index 97f74edc0cfc..8dbe7cbde4c3 100755
--- a/bin/oss-fuzz-setup.sh
+++ b/bin/oss-fuzz-setup.sh
@@ -38,6 +38,7 @@ curl --no-progress-meter -S \
     -C - -O https://dev-www.libreoffice.org/src/$EBOOK_TARBALL \
     -C - -O https://dev-www.libreoffice.org/src/$ETONYEK_TARBALL \
     -C - -O https://dev-www.libreoffice.org/src/$FREEHAND_TARBALL \
+    -C - -O https://dev-www.libreoffice.org/src/$MD4C_TARBALL \
     -C - -O https://dev-www.libreoffice.org/src/$MSPUB_TARBALL \
     -C - -O https://dev-www.libreoffice.org/src/$MWAW_TARBALL \
     -C - -O https://dev-www.libreoffice.org/src/$ODFGEN_TARBALL \
diff --git a/config_host.mk.in b/config_host.mk.in
index 9e94d2a40c28..991a7e3a6f1d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -701,6 +701,7 @@ SYSTEM_LIBXML_FOR_BUILD=@SYSTEM_LIBXML_FOR_BUILD@
 SYSTEM_LIBXSLT=@SYSTEM_LIBXSLT@
 SYSTEM_LIBXSLT_FOR_BUILD=@SYSTEM_LIBXSLT_FOR_BUILD@
 SYSTEM_LPSOLVE=@SYSTEM_LPSOLVE@
+SYSTEM_MD4C=@SYSTEM_MD4C@
 SYSTEM_MDDS=@SYSTEM_MDDS@
 SYSTEM_MARIADB_CONNECTOR_C=@SYSTEM_MARIADB_CONNECTOR_C@
 SYSTEM_MSPUB=@SYSTEM_MSPUB@
@@ -802,6 +803,8 @@ export ZLIB_CFLAGS=$(gb_SPACE)@ZLIB_CFLAGS@
 export ZLIB_LIBS=$(gb_SPACE)@ZLIB_LIBS@
 ZSTD_CFLAGS=$(gb_SPACE)@ZSTD_CFLAGS@
 ZSTD_LIBS=$(gb_SPACE)@ZSTD_LIBS@
+MD4C_CFLAGS=$(gb_SPACE)@MD4C_CFLAGS@
+MD4C_LIBS=$(gb_SPACE)@MD4C_LIBS@
 export ZMF_CFLAGS=$(gb_SPACE)@ZMF_CFLAGS@
 export ZMF_LIBS=$(gb_SPACE)@ZMF_LIBS@
 export GET_TASK_ALLOW_ENTITLEMENT=@GET_TASK_ALLOW_ENTITLEMENT@
diff --git a/configure.ac b/configure.ac
index afe38b969770..2a4d9f37bef3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2470,6 +2470,11 @@ AC_ARG_WITH(system-zstd,
         [Use zstd already on system [default=auto].]),,
     [with_system_zstd=auto])
 
+AC_ARG_WITH(system-md4c,
+    AS_HELP_STRING([--with-system-md4c=@<:@yes|no|auto@:>@],
+        [Use md4c already on system [default=auto].]),,
+    [with_system_md4c=auto])
+
 AC_ARG_WITH(system-jpeg,
     AS_HELP_STRING([--with-system-jpeg],
         [Use jpeg already on system.]),,
@@ -9867,6 +9872,57 @@ AC_SUBST(ZSTD_LIBS)
 AC_SUBST(ZSTD_CFLAGS)
 AC_SUBST(BUILD_TYPE)
 
+dnl ===================================================================
+dnl Check for system md4c
+dnl ===================================================================
+
+if test "x$with_system_md4c" = "xauto"; then
+  case "$_os" in
+    WINNT) with_system_md4c="$with_system_libs" ;;  # follow system-libs on 
Windows
+    *)     with_system_md4c="$with_system_libs" ;;  # follow system-libs on 
Unix
+  esac
+fi
+
+AC_MSG_CHECKING([which md4c to use])
+case "$with_system_md4c" in
+  yes)
+    AC_MSG_RESULT([system])
+    SYSTEM_MD4C=TRUE
+
+    AC_CHECK_HEADER([md4c.h], [],
+      [AC_MSG_ERROR([md4c.h not found. Install system md4c.])])
+
+    AC_CHECK_HEADER([md4c-html.h], [],
+      [AC_MSG_ERROR([md4c-html.h not found. Install system md4c.])])
+
+    AC_CHECK_LIB([md4c], [md_parse],
+      [ MD4C_LIBS="-lmd4c"
+        MD4C_CFLAGS="" ],
+      [ AC_MSG_ERROR([system md4c library not found or broken.]) ])
+
+    AC_CHECK_LIB([md4c-html], [md_html],
+      [ MD4C_LIBS="$MD4C_LIBS -lmd4c-html" ],
+      [ AC_MSG_ERROR([system md4c-html library not found or broken.]) ])
+    ;;
+
+  ""|no)
+    AC_MSG_RESULT([bundled])
+    SYSTEM_MD4C=
+    MD4C_LIBS=""
+    MD4C_CFLAGS="-I\${WORKDIR}/UnpackedTarball/md4c/src"
+    BUILD_TYPE="$BUILD_TYPE MD4C"
+    ;;
+
+  *)
+    AC_MSG_ERROR([Invalid value for --with-system-md4c: $with_system_md4c])
+    ;;
+esac
+
+AC_SUBST(SYSTEM_MD4C)
+AC_SUBST(MD4C_LIBS)
+AC_SUBST(MD4C_CFLAGS)
+AC_SUBST(BUILD_TYPE)
+
 dnl ===================================================================
 dnl Check for system jpeg
 dnl ===================================================================
diff --git a/download.lst b/download.lst
index 7abf3629d126..773056a632e5 100644
--- a/download.lst
+++ b/download.lst
@@ -632,6 +632,11 @@ REVENGE_TARBALL := 
librevenge-0.0.$(REVENGE_VERSION_MICRO).tar.bz2
 # three static lines
 # so that git cherry-pick
 # will not run into conflicts
+MD4C_SHA256SUM := 
55d0111d48fb11883aaee91465e642b8b640775a4d6993c2d0e7a8092758ef21
+MD4C_TARBALL := md4c-release-0.5.2.tar.gz
+# three static lines
+# so that git cherry-pick
+# will not run into conflicts
 RHINO_SHA256SUM := 
42fce6baf1bf789b62bf938b8e8ec18a1ac92c989dd6e7221e9531454cbd97fa
 RHINO_TARBALL := rhino-1.7.15.zip
 # three static lines
diff --git a/external/Module_external.mk b/external/Module_external.mk
index b84568d7e536..5ef092e3db9c 100644
--- a/external/Module_external.mk
+++ b/external/Module_external.mk
@@ -69,6 +69,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\
        $(call gb_Helper_optional,LIBTOMMATH,libtommath) \
        $(call gb_Helper_optional,LXML,lxml) \
        $(call gb_Helper_optional,MARIADB_CONNECTOR_C,mariadb-connector-c) \
+       $(call gb_Helper_optional,MD4C,md4c) \
        $(call gb_Helper_optional,MDDS,mdds) \
        $(call gb_Helper_optional,MDNSRESPONDER,mdnsresponder) \
        $(call gb_Helper_optional,MESON,meson) \
diff --git a/external/md4c/Makefile b/external/md4c/Makefile
new file mode 100644
index 000000000000..c2a2fa141ff6
--- /dev/null
+++ b/external/md4c/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 
100 -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/md4c/Module_md4c.mk b/external/md4c/Module_md4c.mk
new file mode 100644
index 000000000000..dc0318c7890d
--- /dev/null
+++ b/external/md4c/Module_md4c.mk
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 
100 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+$(eval $(call gb_Module_Module,md4c))
+$(eval $(call gb_Module_add_targets,md4c,\
+    UnpackedTarball_md4c \
+    StaticLibrary_md4c \
+))
+# vim: set noet sw=4 ts=4:
diff --git a/external/md4c/README b/external/md4c/README
new file mode 100644
index 000000000000..0e10e1eb4ddd
--- /dev/null
+++ b/external/md4c/README
@@ -0,0 +1 @@
+Fast CommonMark compliant markdown parsing library, available from [ 
https://github.com/mity/md4c.git ]
diff --git a/external/md4c/StaticLibrary_md4c.mk 
b/external/md4c/StaticLibrary_md4c.mk
new file mode 100644
index 000000000000..39a534d2ad03
--- /dev/null
+++ b/external/md4c/StaticLibrary_md4c.mk
@@ -0,0 +1,29 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 
100 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_StaticLibrary_StaticLibrary,md4c))
+
+$(eval $(call gb_StaticLibrary_use_unpacked,md4c,md4c))
+
+$(eval $(call gb_StaticLibrary_set_warnings_disabled,md4c))
+
+# $(eval $(call gb_StaticLibrary_add_defs,md4c,-DMD4C_USE_UTF8))
+
+$(eval $(call gb_StaticLibrary_set_include,md4c,\
+    -I$(gb_UnpackedTarball_workdir)/md4c/src/ \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_StaticLibrary_add_generated_cobjects,md4c,\
+    UnpackedTarball/md4c/src/entity \
+    UnpackedTarball/md4c/src/md4c \
+    UnpackedTarball/md4c/src/md4c-html \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/md4c/UnpackedTarball_md4c.mk 
b/external/md4c/UnpackedTarball_md4c.mk
new file mode 100644
index 000000000000..0f66693d8e8e
--- /dev/null
+++ b/external/md4c/UnpackedTarball_md4c.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 
100 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,md4c))
+$(eval $(call gb_UnpackedTarball_set_tarball,md4c,$(MD4C_TARBALL)))
+
+# vim: set noet sw=4 ts=4:
diff --git a/readlicense_oo/license/license.xml 
b/readlicense_oo/license/license.xml
index 16066d4e041e..64a5e1f460e4 100644
--- a/readlicense_oo/license/license.xml
+++ b/readlicense_oo/license/license.xml
@@ -1440,6 +1440,28 @@
         governed by the terms of the license below:</p>
         <p><a href="#a__LGPL_version_2_1">Jump to LGPL Version 2.1</a></p>
     </div>
+    <div class="MD4C">
+        <h2>md4c</h2>
+        <p>The following software may be included in this product: md4c. Use 
of any of this software is governed by
+        the terms of the license below:</p>
+        <p>The MIT License (MIT)</p>
+        <p>Copyright © 2016-2024 Martin Mitáš</p>
+        <p>Permission is hereby granted, free of charge, to any person 
obtaining a
+        copy of this software and associated documentation files (the 
“Software”),
+        to deal in the Software without restriction, including without 
limitation
+        the rights to use, copy, modify, merge, publish, distribute, 
sublicense,
+        and/or sell copies of the Software, and to permit persons to whom the
+        Software is furnished to do so, subject to the following 
conditions:</p>
+        <p>The above copyright notice and this permission notice shall be 
included
+        in all copies or substantial portions of the Software.</p>
+        <p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 
EXPRESS
+        OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY,
+        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+        THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
OTHER
+        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+        FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
DEALINGS
+        IN THE SOFTWARE.</p>
+    </div>
     <div class="MDDS">
         <h2>mdds</h2>
         <p>The following software may be included in this product: mdds. Use 
of any of this software is governed by the

Reply via email to