commit:     4596df2ad4038c41ed2cc9bec6019207a65b55dc
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 18 18:17:20 2023 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Tue Apr 18 18:22:26 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4596df2a

sci-visualization/labplot: Fix build with >=app-text/discount-3

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../labplot/files/labplot-2.9.0-discount-3.patch   | 98 ++++++++++++++++++++++
 sci-visualization/labplot/labplot-2.9.0-r1.ebuild  |  2 +
 2 files changed, 100 insertions(+)

diff --git a/sci-visualization/labplot/files/labplot-2.9.0-discount-3.patch 
b/sci-visualization/labplot/files/labplot-2.9.0-discount-3.patch
new file mode 100644
index 000000000000..e59c1309888d
--- /dev/null
+++ b/sci-visualization/labplot/files/labplot-2.9.0-discount-3.patch
@@ -0,0 +1,98 @@
+From 06837a859c3cc03b175241d84575f747c2a0a779 Mon Sep 17 00:00:00 2001
+From: Stefan Gerlach <[email protected]>
+Date: Mon, 17 Apr 2023 23:15:19 +0200
+Subject: [PATCH] support discount version 3
+
+cherry-picked (and merged) commits from git master:
+80340872e0fd3780065b847000882cd2c6faaf09
+22c553af43ff2afc42a32f8b9f04c6b426f49300
+---
+ CMakeLists.txt                      |  4 ++++
+ cmake/FindDiscount.cmake            |  9 ++++++++-
+ src/backend/worksheet/TextLabel.cpp | 17 +++++++++++++++--
+ 3 files changed, 27 insertions(+), 3 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index ed478d024..2e28a1aff 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -493,6 +493,10 @@ IF (ENABLE_DISCOUNT)
+               TYPE OPTIONAL)
+       IF (Discount_FOUND)
+               add_definitions (-DHAVE_DISCOUNT)
++              MESSAGE (STATUS "Found Markdown Library Discount 
${Discount_VERSION}")
++              IF (${Discount_VERSION} VERSION_GREATER "2.99")
++                      add_definitions (-DHAVE_DISCOUNT3)
++              ENDIF ()
+       ELSE ()
+               MESSAGE (STATUS "Discount library NOT FOUND.")
+       ENDIF ()
+diff --git a/cmake/FindDiscount.cmake b/cmake/FindDiscount.cmake
+index 4919ad6e1..9dd348649 100644
+--- a/cmake/FindDiscount.cmake
++++ b/cmake/FindDiscount.cmake
+@@ -10,6 +10,11 @@
+ # SPDX-FileCopyrightText: 2018 Sune Vuorela <[email protected]>
+ # SPDX-License-Identifier: BSD-3-Clause
+ 
++find_package(PkgConfig QUIET)
++pkg_check_modules(PC_LIBMARKDOWN libmarkdown QUIET)
++
++set(Discount_VERSION ${PC_LIBMARKDOWN_VERSION})
++
+ if (Discount_INCLUDE_DIR AND Discount_LIBRARIES)
+ 
+   # Already in cache
+@@ -19,10 +24,12 @@ else (Discount_INCLUDE_DIR AND Discount_LIBRARIES)
+ 
+   find_library (Discount_LIBRARIES
+     NAMES markdown libmarkdown
++    HINTS ${PC_LIBMARKDOWN_LIBRARY_DIRS}
+   )
+ 
+   find_path (Discount_INCLUDE_DIR
+     NAMES mkdio.h
++    HINTS ${PC_LIBMARKDOWN_INCLUDE_DIRS}
+   )
+ 
+   include (FindPackageHandleStandardArgs)
+@@ -30,7 +37,7 @@ else (Discount_INCLUDE_DIR AND Discount_LIBRARIES)
+ 
+ endif (Discount_INCLUDE_DIR AND Discount_LIBRARIES)
+ 
+-mark_as_advanced(Discount_INCLUDE_DIR Discount_LIBRARIES)
++mark_as_advanced(Discount_INCLUDE_DIR Discount_LIBRARIES Discount_VERSION)
+ 
+ if (Discount_FOUND)
+    add_library(Discount::Lib UNKNOWN IMPORTED)
+diff --git a/src/backend/worksheet/TextLabel.cpp 
b/src/backend/worksheet/TextLabel.cpp
+index 815dcb785..1c85c0e9e 100644
+--- a/src/backend/worksheet/TextLabel.cpp
++++ b/src/backend/worksheet/TextLabel.cpp
+@@ -576,8 +576,21 @@ void TextLabelPrivate::updateText() {
+       case TextLabel::Mode::Markdown: {
+ #ifdef HAVE_DISCOUNT
+               auto mdCharArray = textWrapper.text.toUtf8();
+-              MMIOT* mdHandle = mkd_string(mdCharArray.data(), 
mdCharArray.size()+1, 0);
+-              if(!mkd_compile(mdHandle, MKD_LATEX | MKD_FENCEDCODE | 
MKD_GITHUBTAGS)) {
++#ifdef HAVE_DISCOUNT3
++              MMIOT* mdHandle = mkd_string(mdCharArray.data(), 
mdCharArray.size() + 1, nullptr);
++
++              mkd_flag_t* v3flags = mkd_flags();
++              mkd_set_flag_num(v3flags, MKD_LATEX);
++              mkd_set_flag_num(v3flags, MKD_FENCEDCODE);
++              mkd_set_flag_num(v3flags, MKD_GITHUBTAGS);
++
++              if (!mkd_compile(mdHandle, v3flags)) {
++#else
++              MMIOT* mdHandle = mkd_string(mdCharArray.data(), 
mdCharArray.size() + 1, 0);
++
++              unsigned int flags = MKD_LATEX | MKD_FENCEDCODE | 
MKD_GITHUBTAGS;
++              if (!mkd_compile(mdHandle, flags)) {
++#endif
+                       DEBUG(Q_FUNC_INFO << ", Failed to compile the markdown 
document");
+                       mkd_cleanup(mdHandle);
+                       return;
+-- 
+2.40.0
+

diff --git a/sci-visualization/labplot/labplot-2.9.0-r1.ebuild 
b/sci-visualization/labplot/labplot-2.9.0-r1.ebuild
index c45f80b7f620..30d2be63d7c4 100644
--- a/sci-visualization/labplot/labplot-2.9.0-r1.ebuild
+++ b/sci-visualization/labplot/labplot-2.9.0-r1.ebuild
@@ -72,6 +72,8 @@ BDEPEND="
        sys-devel/gettext
 "
 
+PATCHES=( "${FILESDIR}/${P}-discount-3.patch" )
+
 src_configure() {
        local mycmakeargs=(
                -DENABLE_MQTT=OFF # not packaged

Reply via email to