Skip to content

Commit 08e66b9

Browse files
committed
Allow compiling with markdown3
Currently compilation fails with: /build/src/classes/renderer/markdown.c:191:20: error: variable or field 'flags' declared void According to comment [1], markdown3 introduces backward incompatibility with respect to document flags. This commit adds conditionally compiled code that allows building pdfpc with both markdown versions 2 and 3. The used cmake operator VERSION_GREATER_EQUAL requires cmake 3.7 so we bump minimal cmake version requirement. Fixes pdfpc#682 [1]: pdfpc#682 (comment)
1 parent 1de2963 commit 08e66b9

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project("pdfpc" C)
2-
cmake_minimum_required(VERSION 3.0)
2+
cmake_minimum_required(VERSION 3.7)
33

44
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala)
55

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ if (MDVIEW OR REST)
3232
pkg_check_modules(MARKDOWN REQUIRED libmarkdown)
3333
endif ()
3434

35+
if ("${MARKDOWN_VERSION}" VERSION_GREATER_EQUAL 3)
36+
set(EXTRA_VALA_OPTIONS ${EXTRA_VALA_OPTIONS} -D MARKDOWN3)
37+
endif ()
38+
3539
if (MDVIEW)
3640
pkg_check_modules(WEBKIT REQUIRED webkit2gtk-4.0)
3741
set(MDVIEW_PACKAGES webkit2gtk-4.0)

src/classes/renderer/markdown.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
namespace pdfpc.Renderer {
2424
public class MD {
2525
public static string render(string? text = "", bool plain_text = false) {
26+
#if MARKDOWN3
27+
var flags = new Markdown.DocumentFlags();
28+
flags.set(Markdown.DocumentFlag.NO_EXT);
29+
#else
2630
Markdown.DocumentFlags flags = Markdown.DocumentFlags.NO_EXT;
31+
#endif
2732

2833
string html;
2934
if (text != "" && plain_text) {

src/libmarkdown.vapi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,23 @@ namespace Markdown
9595
public void ref_prefix (string prefix);
9696
}
9797

98+
#if MARKDOWN3
99+
[Compact]
100+
[CCode (cname = "mkd_flag_t", free_function = "mkd_free_flags")]
101+
public class DocumentFlags {
102+
[CCode (cname = "mkd_flags")]
103+
public DocumentFlags();
104+
[CCode (cname = "mkd_set_flag_num")]
105+
public void set (DocumentFlag flag);
106+
}
107+
108+
[CCode (cprefix = "MKD_")]
109+
public enum DocumentFlag
110+
#else
98111
[Flags]
99112
[CCode (cname = "mkd_flag_t", cprefix = "MKD_")]
100113
public enum DocumentFlags
114+
#endif
101115
{
102116
NOLINKS,
103117
NOIMAGE,

0 commit comments

Comments
 (0)