geany-plugins icon indicating copy to clipboard operation
geany-plugins copied to clipboard

Markdown: replace Discount and PEG Markdown with CMark

Open codebrainz opened this issue 7 years ago • 6 comments

Adds the CMark source into the plugin tree to be used when there is no libcmark package available using pkg-config. At present, my distro only ships the cmark utility but not the accompanying library or development packages, as well I do not believe msys2 provides a CMark package for Windows, so for now it will remain embedded as a backup, replacing the previously embedded PEG Markdown and the externally linked Discount markdown library.

The version embedded is v0.28.3. A few trivial changes were made to allow libcmark to compile without its original CMake infrastructure. Only cmark.h and cmark_version.h were modified.

TODO: create a patch so the simple changes to upstream CMark library can be mechanically applied to newer versions.

All future complaints/requests about supporting various Markdown extensions should be addressed directly to the CommonMark Project.

Fixes: #589, #651.

codebrainz avatar May 24 '18 08:05 codebrainz

Also ping @evgeni, @sardemff7 et al. :smile:

codebrainz avatar May 24 '18 08:05 codebrainz

For anyone interested in reviewing the non-build-related code, the crux of it is here.

codebrainz avatar May 24 '18 08:05 codebrainz

For future me, diffs from upstream:

@@ -1,10 +1,13 @@
 #ifndef CMARK_H
 #define CMARK_H
 
+#include <stdbool.h>
 #include <stdio.h>
-#include <cmark_export.h>
 #include <cmark_version.h>
 
+#define CMARK_EXPORT
+#define CMARK_INLINE inline
+
 #ifdef __cplusplus
 extern "C" {
 #endif

and

@@ -1,7 +1,7 @@
 #ifndef CMARK_VERSION_H
 #define CMARK_VERSION_H
 
-#define CMARK_VERSION ((@PROJECT_VERSION_MAJOR@ << 16) | (@PROJECT_VERSION_MINOR@ << 8)  | @PROJECT_VERSION_PATCH@)
-#define CMARK_VERSION_STRING "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"
+#define CMARK_VERSION ((0 << 16) | (28 << 8)  | 3)
+#define CMARK_VERSION_STRING "0.28.3"
 
 #endif

codebrainz avatar May 24 '18 08:05 codebrainz

@codebrainz why did you ping me? :) debian maintenance is done mostly by @hyperair these days - I am rather busy with other things. but cmark is available in debian and i guess we would not really care what you embed as a fallback.

evgeni avatar May 24 '18 12:05 evgeni

@evgeni sorry, I wasn't aware, I just wanted to get some people who know the project and about packaging and Autotools to take a look, since that's mostly what this PR affects. Sorry for the (now two) pings. I did see that a libcmark package was added very recently, but I just embedded it until it's widely available. Thanks for your time.

codebrainz avatar May 24 '18 23:05 codebrainz

I've recently upgraded to Ubuntu 20.04 and I see that now libcmark is packaged separately, unfortunately it has a broken pkg-config file. I was also excited to see that there's a Github fork libcmark-gfm that features Github Flavoured Markdown, which would add support for some of the widely requested extensions (ex. tables), but again, unfortunately the pkg-config file for this one is entirely missing (it's upstream but not in the Ubuntu package).

Grrrrr....

codebrainz avatar May 27 '20 23:05 codebrainz