Skip to content

Commit

Permalink
ADDED: Add simple API method
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcher committed Aug 13, 2024
1 parent 655c090 commit 99976a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libMultiMarkdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/mmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 99976a4

Please sign in to comment.