medit/tests/markup.c

75 lines
1.5 KiB
C
Raw Normal View History

2005-06-23 13:18:45 -07:00
/*
* tests/markup.c
*
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
2005-06-23 13:18:45 -07:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
2005-06-22 11:20:32 -07:00
#include "mooutils/moomarkup.h"
#include <string.h>
#include <glib.h>
const char *markup =
"<blah>\n"
"<!-- COMMENT -->\n"
" <bam a=\"ddd\" g=\"ferfer\"> ffff </bam>\n"
"<!-- COMMENT -->\n"
" <rgrg/>\n"
"</blah>\n"
"<!-- COMMENT -->\n"
"<fffff/>\n"
;
int main (int argc, char *argv[])
{
2005-06-23 13:18:45 -07:00
gboolean print = TRUE;
const char *file = NULL;
MooMarkupDoc *doc = NULL;
GError *err = NULL;
if (argc > 1)
file = argv[1];
if (argc > 2)
print = FALSE;
2005-06-22 11:20:32 -07:00
if (file)
doc = moo_markup_parse_file (file, &err);
else
doc = moo_markup_parse_memory (markup, -1, &err);
2005-06-23 13:18:45 -07:00
if (!doc)
{
2005-06-22 11:20:32 -07:00
g_print ("ERROR\n");
2005-06-23 13:18:45 -07:00
if (err)
{
2005-06-22 11:20:32 -07:00
g_print (err->message);
g_error_free (err);
}
}
2005-06-23 13:18:45 -07:00
else
{
2005-06-22 11:20:32 -07:00
g_print ("SUCCESS\n");
2005-06-23 13:18:45 -07:00
if (print)
{
char *text = moo_markup_node_get_string (MOO_MARKUP_NODE (doc));
2005-06-22 11:20:32 -07:00
g_print ("%s\n", text);
g_free (text);
g_print ("------------------------------\n");
}
2005-06-23 13:18:45 -07:00
2005-06-22 11:20:32 -07:00
moo_markup_doc_unref (doc);
}
2005-09-04 21:24:21 -07:00
return 0;
2005-06-22 11:20:32 -07:00
}