From: Andrea Zagli Date: Tue, 28 Jul 2020 15:48:03 +0000 (+0200) Subject: Get singles properties. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=e7ef408b74eace915e6e7a9f641c3b3c4b0c0fc8;p=libzakgorg Get singles properties. --- diff --git a/src/parser.c b/src/parser.c index 301cd6d..fb7e765 100644 --- a/src/parser.c +++ b/src/parser.c @@ -264,8 +264,8 @@ zak_gorg_parser_parse (ZakGorgParser *zak_gorg_parser) regex_header = g_regex_new ("[*]+ ", 0, 0, NULL); regex_tags = g_regex_new (":[^ .]*:$", 0, 0, NULL); - regex_properties = g_regex_new ("^[ ]*:PROPERTIES:\n(.*\n)*[ ]*:END:\n", 0, 0, NULL); - regex_property = g_regex_new (":[^ .]*:.*", 0, 0, NULL); + regex_properties = g_regex_new ("^[ ]*:PROPERTIES:\n((.*\n)*)[ ]*:END:\n", 0, 0, NULL); + regex_property = g_regex_new ("^[ ]*:[^ .]*:.*\n$", 0, 0, NULL); root = g_node_get_root (zak_gorg_parser->nodes); @@ -296,7 +296,18 @@ zak_gorg_parser_parse (ZakGorgParser *zak_gorg_parser) if (g_match_info_fetch (match_info, 0) != NULL) { - g_warning ("PROP %s", g_match_info_fetch (match_info, 0)); + gchar **props; + guint f; + + g_warning ("PROPS %s", g_match_info_fetch (match_info, 0)); + + props = g_strsplit (g_match_info_fetch (match_info, 1), "\n", -1); + + f = g_strv_length (props); + for (l = 0; l < f; l++) + { + g_warning ("PROP %s", props[l]); + } } g_match_info_free (match_info); @@ -372,4 +383,6 @@ zak_gorg_parser_parse (ZakGorgParser *zak_gorg_parser) g_regex_unref (regex_header); g_regex_unref (regex_tags); + g_regex_unref (regex_properties); + g_regex_unref (regex_property); } diff --git a/tests/simple.org b/tests/simple.org index 524ab8b..9748af0 100644 --- a/tests/simple.org +++ b/tests/simple.org @@ -5,6 +5,7 @@ body with no space * second line :tag1: :PROPERTIES: :prop1: val1 + :property2: value2 :END: the body of the second line it's multiline body