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 <thorsten.behrens@allotropia.de>
This commit is contained in:
Ujjawal Kumar
2025-06-22 14:03:08 +02:00
committed by Thorsten Behrens
parent f86536104f
commit 8539f39c84
13 changed files with 170 additions and 0 deletions
+1
View File
@@ -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) \
+17
View File
@@ -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),)
+1
View File
@@ -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 \
+3
View File
@@ -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@
+56
View File
@@ -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 ===================================================================
+5
View File
@@ -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
+1
View File
@@ -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) \
+7
View File
@@ -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:
+14
View File
@@ -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:
+1
View File
@@ -0,0 +1 @@
Fast CommonMark compliant markdown parsing library, available from [ https://github.com/mity/md4c.git ]
+29
View File
@@ -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:
+13
View File
@@ -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:
+22
View File
@@ -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