parent
869cb20eaf
commit
aa8a9a003b
@ -0,0 +1,34 @@
|
||||
#include "md_pango.h"
|
||||
|
||||
gchar *md_pango_render(gchar *markup, gint length)
|
||||
{
|
||||
gchar *str;
|
||||
gchar *str2;
|
||||
GRegex *regex;
|
||||
|
||||
regex = g_regex_new("\\>", 0, 0, NULL);
|
||||
str = g_regex_replace(regex, markup, -1, 0, ">", 0, NULL);
|
||||
g_regex_unref(regex);
|
||||
|
||||
regex = g_regex_new("\\<", 0, 0, NULL);
|
||||
str2 = g_regex_replace(regex, str, -1, 0, "<", 0, NULL);
|
||||
g_regex_unref(regex);
|
||||
g_free(str);
|
||||
|
||||
regex = g_regex_new("\\*{2}([^\\*]*)\\*{2}", 0, 0, NULL);
|
||||
str = g_regex_replace(regex, str2, -1, 0, "<b>\\1</b>", 0, NULL);
|
||||
g_regex_unref(regex);
|
||||
g_free(str2);
|
||||
|
||||
regex = g_regex_new("\\*([^\\*]*)\\*", 0, 0, NULL);
|
||||
str2 = g_regex_replace(regex, str, -1, 0, "<i>\\1</i>", 0, NULL);
|
||||
g_regex_unref(regex);
|
||||
g_free(str);
|
||||
|
||||
regex = g_regex_new("\\!\\[([^\\]]*)\\]\\(([^\\)]*)\\)", 0, 0, NULL);
|
||||
str = g_regex_replace(regex, str2, -1, 0, "-- Image \\1 (\\2) --", 0, NULL);
|
||||
g_regex_unref(regex);
|
||||
g_free(str2);
|
||||
|
||||
return str;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
#ifndef MD_PANGO_H
|
||||
#define MD_PANGO_H
|
||||
|
||||
#include <glib.h>
|
||||
gchar *md_pango_render(gchar *markup, gint length);
|
||||
|
||||
#endif /* MD_PANGO_H */
|
Loading…
Reference in new issue