2 * @file miranda-markup.c
6 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "sipe-backend.h"
29 gchar
*sipe_backend_markup_css_property(const gchar
*style
,
32 const gchar
*css_str
= style
;
33 const gchar
*css_value_start
;
34 const gchar
*css_value_end
;
38 g_return_val_if_fail(opt
!= NULL
, NULL
);
43 /* find the CSS property */
46 /* skip whitespace characters */
47 while (*css_str
&& g_ascii_isspace(*css_str
))
49 if (!g_ascii_isalpha(*css_str
))
51 if (g_ascii_strncasecmp(css_str
, opt
, strlen(opt
)))
53 /* go to next css property positioned after the next ';' */
54 while (*css_str
&& *css_str
!= '"' && *css_str
!= ';')
64 /* find the CSS value position in the string */
65 css_str
+= strlen(opt
);
66 while (*css_str
&& g_ascii_isspace(*css_str
))
71 while (*css_str
&& g_ascii_isspace(*css_str
))
73 if (*css_str
== '\0' || *css_str
== '"' || *css_str
== ';')
76 /* mark the CSS value */
77 css_value_start
= css_str
;
78 while (*css_str
&& *css_str
!= '"' && *css_str
!= ';')
80 css_value_end
= css_str
- 1;
82 /* Removes trailing whitespace */
83 while (css_value_end
> css_value_start
&& g_ascii_isspace(*css_value_end
))
86 tmp
= g_strndup(css_value_start
, css_value_end
- css_value_start
+ 1);
87 // ret = purple_unescape_html(tmp);
94 gchar
*sipe_backend_markup_strip_html(const gchar
*html
)
96 char *tmp
= g_malloc(strlen(html
)+1);
99 gboolean in_tag
= FALSE
;
101 for ( src
=html
, tgt
=tmp
; *src
; src
++ )
103 if (*src
== '<') in_tag
= TRUE
;
104 if (!in_tag
) *tgt
++ = *src
;
105 if (*src
== '>') in_tag
= FALSE
;