From 4409c8cca6ec64fea8fe70b75cdf9ddc98273663 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Fri, 13 Jun 2014 19:16:26 +0200 Subject: [PATCH] Expose parse_markdown to Nasal. --- src/Scripting/NasalSys.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 73c233372..cc56043d5 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -697,6 +698,19 @@ static naRef f_parsexml(naContext c, naRef me, int argc, naRef* args) return naStr_fromdata(naNewString(c), const_cast(file), strlen(file)); } +/** + * Parse very simple and small subset of markdown + * + * parse_markdown(src) + */ +static naRef f_parse_markdown(naContext c, naRef me, int argc, naRef* args) +{ + nasal::CallContext ctx(c, argc, args); + return ctx.to_nasal( + simgear::SimpleMarkdown::parse(ctx.requireArg(0)) + ); +} + // Return UNIX epoch time in seconds. static naRef f_systime(naContext c, naRef me, int argc, naRef* args) { @@ -735,6 +749,7 @@ static struct { const char* name; naCFunction func; } funcs[] = { { "resolvepath", f_resolveDataPath }, { "finddata", f_findDataDir }, { "parsexml", f_parsexml }, + { "parse_markdown", f_parse_markdown }, { "systime", f_systime }, { 0, 0 } }; -- 2.39.5