From 99976a4026b99c17e3b18269b4ec1f888b379219 Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Mon, 12 Aug 2024 22:10:32 -0400 Subject: [PATCH] ADDED: Add simple API method --- src/libMultiMarkdown.h | 5 +++++ src/mmd.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/libMultiMarkdown.h b/src/libMultiMarkdown.h index 49a1c96..f7877e2 100644 --- a/src/libMultiMarkdown.h +++ b/src/libMultiMarkdown.h @@ -109,6 +109,11 @@ DString * mmd_string_convert_opml_to_text(const char * source); DString * mmd_string_convert_itmz_to_text(const char * source); +/// Convert MMD text to AST, with specified extensions, and language +/// Returned token tree must be freed +token * mmd_string_parse(const char * source, unsigned long extensions); + + /// Convert MMD text to specified format, with specified extensions, and language /// Returned char * must be freed char * mmd_string_convert(const char * source, unsigned long extensions, short format, short language); diff --git a/src/mmd.c b/src/mmd.c index 32e495e..41f2d28 100644 --- a/src/mmd.c +++ b/src/mmd.c @@ -2802,6 +2802,22 @@ void mmd_engine_update_metavalue_for_key(mmd_engine * e, const char * key, const } +/// Convert MMD text to AST, with specified extensions, and language +/// Returned token tree must be freed +token * mmd_string_parse(const char * source, unsigned long extensions) { + mmd_engine * e = mmd_engine_create_with_string(source, extensions); + + mmd_engine_parse_string(e); + + token * result = mmd_engine_root(e); + e->root = NULL; + + mmd_engine_free(e, true); + + return result; +} + + /// Convert MMD text to specified format, with specified extensions, and language /// Returned char * must be freed char * mmd_string_convert(const char * source, unsigned long extensions, short format, short language) {