From 9106b01b92cf3ecd26755fea86af04ff8f91e0df Mon Sep 17 00:00:00 2001 From: Kristopher Baker Date: Wed, 19 Jun 2019 14:50:03 +0900 Subject: [PATCH] Update for latest changes in cmark-gfm. Version bump --- .../include/cmark-gfm-core-extensions.h | 26 +++++++++++++++++-- Sources/libcmark_gfm/tasklist.c | 19 +++++++++++++- libcmark_gfm.podspec | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Sources/libcmark_gfm/include/cmark-gfm-core-extensions.h b/Sources/libcmark_gfm/include/cmark-gfm-core-extensions.h index 126f2c7..0645915 100644 --- a/Sources/libcmark_gfm/include/cmark-gfm-core-extensions.h +++ b/Sources/libcmark_gfm/include/cmark-gfm-core-extensions.h @@ -7,7 +7,7 @@ extern "C" { #include "cmark-gfm-extension_api.h" #include "cmark-gfm-extensions_export.h" -#include "config.h" +#include "config.h" // for bool #include CMARK_GFM_EXTENSIONS_EXPORT @@ -16,14 +16,36 @@ void cmark_gfm_core_extensions_ensure_registered(void); CMARK_GFM_EXTENSIONS_EXPORT uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node); +/** Sets the number of columns for the table, returning 1 on success and 0 on error. + */ +CMARK_GFM_EXTENSIONS_EXPORT +int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns); + CMARK_GFM_EXTENSIONS_EXPORT uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node); +/** Sets the alignments for the table, returning 1 on success and 0 on error. + */ +CMARK_GFM_EXTENSIONS_EXPORT +int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments); + CMARK_GFM_EXTENSIONS_EXPORT int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node); +/** Sets whether the node is a table header row, returning 1 on success and 0 on error. + */ +CMARK_GFM_EXTENSIONS_EXPORT +int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header); + +CMARK_GFM_EXTENSIONS_EXPORT +bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node); +/* For backwards compatibility */ +#define cmark_gfm_extensions_tasklist_is_checked cmark_gfm_extensions_get_tasklist_item_checked + +/** Sets whether a tasklist item is "checked" (completed), returning 1 on success and 0 on error. + */ CMARK_GFM_EXTENSIONS_EXPORT -bool cmark_gfm_extensions_tasklist_state_is_checked(cmark_node *node); +int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked); #ifdef __cplusplus } diff --git a/Sources/libcmark_gfm/tasklist.c b/Sources/libcmark_gfm/tasklist.c index 4af7637..65f7481 100644 --- a/Sources/libcmark_gfm/tasklist.c +++ b/Sources/libcmark_gfm/tasklist.c @@ -16,7 +16,24 @@ static const char *get_type_string(cmark_syntax_extension *extension, cmark_node return TYPE_STRING; } -bool cmark_gfm_extensions_tasklist_state_is_checked(cmark_node *node) { + +// Return 1 if state was set, 0 otherwise +int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked) { + // The node has to exist, and be an extension, and actually be the right type in order to get the value. + if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING)) + return 0; + + if (is_checked) { + node->as.opaque = (void *)CMARK_TASKLIST_CHECKED; + return 1; + } + else { + node->as.opaque = (void *)CMARK_TASKLIST_NOCHECKED; + return 1; + } +} + +bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node) { if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING)) return false; diff --git a/libcmark_gfm.podspec b/libcmark_gfm.podspec index 146cd04..15a4b4a 100755 --- a/libcmark_gfm.podspec +++ b/libcmark_gfm.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "libcmark_gfm" - s.version = "0.29.2" + s.version = "0.29.3" s.summary = "Swift compatible framework for cmark-gfm" s.description = <<-DESC