mathematical 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/mathematical/extconf.rb +14 -0
- data/ext/mathematical/itex2MML.h +63 -0
- data/ext/mathematical/lasemrender.c +257 -0
- data/ext/mathematical/lex.yy.c +6548 -0
- data/ext/mathematical/lsm.c +31 -0
- data/ext/mathematical/lsm.h +39 -0
- data/ext/mathematical/lsmattributes.c +279 -0
- data/ext/mathematical/lsmattributes.h +75 -0
- data/ext/mathematical/lsmcairo.c +598 -0
- data/ext/mathematical/lsmcairo.h +51 -0
- data/ext/mathematical/lsmdebug.c +183 -0
- data/ext/mathematical/lsmdebug.h +73 -0
- data/ext/mathematical/lsmdom.h +43 -0
- data/ext/mathematical/lsmdomcharacterdata.c +114 -0
- data/ext/mathematical/lsmdomcharacterdata.h +59 -0
- data/ext/mathematical/lsmdomdocument.c +255 -0
- data/ext/mathematical/lsmdomdocument.h +75 -0
- data/ext/mathematical/lsmdomdocumentfragment.c +81 -0
- data/ext/mathematical/lsmdomdocumentfragment.h +55 -0
- data/ext/mathematical/lsmdomelement.c +148 -0
- data/ext/mathematical/lsmdomelement.h +62 -0
- data/ext/mathematical/lsmdomentities.c +2166 -0
- data/ext/mathematical/lsmdomentities.h +35 -0
- data/ext/mathematical/lsmdomenumtypes.c +99 -0
- data/ext/mathematical/lsmdomenumtypes.h +26 -0
- data/ext/mathematical/lsmdomimplementation.c +82 -0
- data/ext/mathematical/lsmdomimplementation.h +41 -0
- data/ext/mathematical/lsmdomnamednodemap.c +118 -0
- data/ext/mathematical/lsmdomnamednodemap.h +64 -0
- data/ext/mathematical/lsmdomnode.c +737 -0
- data/ext/mathematical/lsmdomnode.h +122 -0
- data/ext/mathematical/lsmdomnodelist.c +70 -0
- data/ext/mathematical/lsmdomnodelist.h +58 -0
- data/ext/mathematical/lsmdomparser.c +461 -0
- data/ext/mathematical/lsmdomparser.h +54 -0
- data/ext/mathematical/lsmdomtext.c +82 -0
- data/ext/mathematical/lsmdomtext.h +55 -0
- data/ext/mathematical/lsmdomtypes.h +44 -0
- data/ext/mathematical/lsmdomview.c +422 -0
- data/ext/mathematical/lsmdomview.h +94 -0
- data/ext/mathematical/lsmitex.c +76 -0
- data/ext/mathematical/lsmitex.h +36 -0
- data/ext/mathematical/lsmmathml.h +66 -0
- data/ext/mathematical/lsmmathmlactionelement.c +93 -0
- data/ext/mathematical/lsmmathmlactionelement.h +57 -0
- data/ext/mathematical/lsmmathmlaligngroupelement.c +102 -0
- data/ext/mathematical/lsmmathmlaligngroupelement.h +56 -0
- data/ext/mathematical/lsmmathmlalignmarkelement.c +102 -0
- data/ext/mathematical/lsmmathmlalignmarkelement.h +56 -0
- data/ext/mathematical/lsmmathmlattributes.c +197 -0
- data/ext/mathematical/lsmmathmlattributes.h +126 -0
- data/ext/mathematical/lsmmathmldocument.c +304 -0
- data/ext/mathematical/lsmmathmldocument.h +61 -0
- data/ext/mathematical/lsmmathmlelement.c +491 -0
- data/ext/mathematical/lsmmathmlelement.h +107 -0
- data/ext/mathematical/lsmmathmlenums.c +429 -0
- data/ext/mathematical/lsmmathmlenums.h +182 -0
- data/ext/mathematical/lsmmathmlenumtypes.c +666 -0
- data/ext/mathematical/lsmmathmlenumtypes.h +90 -0
- data/ext/mathematical/lsmmathmlerrorelement.c +58 -0
- data/ext/mathematical/lsmmathmlerrorelement.h +56 -0
- data/ext/mathematical/lsmmathmlfencedelement.c +178 -0
- data/ext/mathematical/lsmmathmlfencedelement.h +65 -0
- data/ext/mathematical/lsmmathmlfractionelement.c +253 -0
- data/ext/mathematical/lsmmathmlfractionelement.h +62 -0
- data/ext/mathematical/lsmmathmlglyphtableams.c +597 -0
- data/ext/mathematical/lsmmathmlglyphtableams.h +45 -0
- data/ext/mathematical/lsmmathmlitexelement.c +187 -0
- data/ext/mathematical/lsmmathmlitexelement.h +60 -0
- data/ext/mathematical/lsmmathmllayoututils.c +191 -0
- data/ext/mathematical/lsmmathmllayoututils.h +58 -0
- data/ext/mathematical/lsmmathmlmathelement.c +204 -0
- data/ext/mathematical/lsmmathmlmathelement.h +81 -0
- data/ext/mathematical/lsmmathmloperatordictionary.c +3332 -0
- data/ext/mathematical/lsmmathmloperatordictionary.h +54 -0
- data/ext/mathematical/lsmmathmloperatorelement.c +307 -0
- data/ext/mathematical/lsmmathmloperatorelement.h +73 -0
- data/ext/mathematical/lsmmathmlpaddedelement.c +58 -0
- data/ext/mathematical/lsmmathmlpaddedelement.h +56 -0
- data/ext/mathematical/lsmmathmlphantomelement.c +71 -0
- data/ext/mathematical/lsmmathmlphantomelement.h +56 -0
- data/ext/mathematical/lsmmathmlpresentationcontainer.c +43 -0
- data/ext/mathematical/lsmmathmlpresentationcontainer.h +54 -0
- data/ext/mathematical/lsmmathmlpresentationtoken.c +303 -0
- data/ext/mathematical/lsmmathmlpresentationtoken.h +83 -0
- data/ext/mathematical/lsmmathmlradicalelement.c +266 -0
- data/ext/mathematical/lsmmathmlradicalelement.h +71 -0
- data/ext/mathematical/lsmmathmlrowelement.c +58 -0
- data/ext/mathematical/lsmmathmlrowelement.h +56 -0
- data/ext/mathematical/lsmmathmlscriptelement.c +282 -0
- data/ext/mathematical/lsmmathmlscriptelement.h +78 -0
- data/ext/mathematical/lsmmathmlsemanticselement.c +84 -0
- data/ext/mathematical/lsmmathmlsemanticselement.h +56 -0
- data/ext/mathematical/lsmmathmlspaceelement.c +142 -0
- data/ext/mathematical/lsmmathmlspaceelement.h +60 -0
- data/ext/mathematical/lsmmathmlstringelement.c +123 -0
- data/ext/mathematical/lsmmathmlstringelement.h +58 -0
- data/ext/mathematical/lsmmathmlstyle.c +130 -0
- data/ext/mathematical/lsmmathmlstyle.h +81 -0
- data/ext/mathematical/lsmmathmlstyleelement.c +307 -0
- data/ext/mathematical/lsmmathmlstyleelement.h +87 -0
- data/ext/mathematical/lsmmathmltablecellelement.c +122 -0
- data/ext/mathematical/lsmmathmltablecellelement.h +62 -0
- data/ext/mathematical/lsmmathmltableelement.c +545 -0
- data/ext/mathematical/lsmmathmltableelement.h +78 -0
- data/ext/mathematical/lsmmathmltablerowelement.c +120 -0
- data/ext/mathematical/lsmmathmltablerowelement.h +64 -0
- data/ext/mathematical/lsmmathmltraits.c +819 -0
- data/ext/mathematical/lsmmathmltraits.h +119 -0
- data/ext/mathematical/lsmmathmltypes.h +66 -0
- data/ext/mathematical/lsmmathmlunderoverelement.c +485 -0
- data/ext/mathematical/lsmmathmlunderoverelement.h +82 -0
- data/ext/mathematical/lsmmathmlutils.c +170 -0
- data/ext/mathematical/lsmmathmlutils.h +50 -0
- data/ext/mathematical/lsmmathmlview.c +1048 -0
- data/ext/mathematical/lsmmathmlview.h +164 -0
- data/ext/mathematical/lsmproperties.c +418 -0
- data/ext/mathematical/lsmproperties.h +85 -0
- data/ext/mathematical/lsmstr.c +231 -0
- data/ext/mathematical/lsmstr.h +114 -0
- data/ext/mathematical/lsmsvg.h +67 -0
- data/ext/mathematical/lsmsvgaelement.c +73 -0
- data/ext/mathematical/lsmsvgaelement.h +55 -0
- data/ext/mathematical/lsmsvgattributes.h +118 -0
- data/ext/mathematical/lsmsvgcircleelement.c +153 -0
- data/ext/mathematical/lsmsvgcircleelement.h +59 -0
- data/ext/mathematical/lsmsvgclippathelement.c +134 -0
- data/ext/mathematical/lsmsvgclippathelement.h +59 -0
- data/ext/mathematical/lsmsvgcolors.c +212 -0
- data/ext/mathematical/lsmsvgcolors.h +39 -0
- data/ext/mathematical/lsmsvgdefselement.c +74 -0
- data/ext/mathematical/lsmsvgdefselement.h +55 -0
- data/ext/mathematical/lsmsvgdocument.c +288 -0
- data/ext/mathematical/lsmsvgdocument.h +64 -0
- data/ext/mathematical/lsmsvgelement.c +373 -0
- data/ext/mathematical/lsmsvgelement.h +81 -0
- data/ext/mathematical/lsmsvgellipseelement.c +158 -0
- data/ext/mathematical/lsmsvgellipseelement.h +60 -0
- data/ext/mathematical/lsmsvgenums.c +544 -0
- data/ext/mathematical/lsmsvgenums.h +357 -0
- data/ext/mathematical/lsmsvgenumtypes.c +1083 -0
- data/ext/mathematical/lsmsvgenumtypes.h +111 -0
- data/ext/mathematical/lsmsvgfilterblend.c +105 -0
- data/ext/mathematical/lsmsvgfilterblend.h +58 -0
- data/ext/mathematical/lsmsvgfiltercomposite.c +109 -0
- data/ext/mathematical/lsmsvgfiltercomposite.h +58 -0
- data/ext/mathematical/lsmsvgfilterelement.c +266 -0
- data/ext/mathematical/lsmsvgfilterelement.h +66 -0
- data/ext/mathematical/lsmsvgfilterflood.c +86 -0
- data/ext/mathematical/lsmsvgfilterflood.h +55 -0
- data/ext/mathematical/lsmsvgfiltergaussianblur.c +114 -0
- data/ext/mathematical/lsmsvgfiltergaussianblur.h +57 -0
- data/ext/mathematical/lsmsvgfiltermerge.c +98 -0
- data/ext/mathematical/lsmsvgfiltermerge.h +55 -0
- data/ext/mathematical/lsmsvgfiltermergenode.c +87 -0
- data/ext/mathematical/lsmsvgfiltermergenode.h +57 -0
- data/ext/mathematical/lsmsvgfilteroffset.c +112 -0
- data/ext/mathematical/lsmsvgfilteroffset.h +58 -0
- data/ext/mathematical/lsmsvgfilterprimitive.c +168 -0
- data/ext/mathematical/lsmsvgfilterprimitive.h +66 -0
- data/ext/mathematical/lsmsvgfilterspecularlighting.c +127 -0
- data/ext/mathematical/lsmsvgfilterspecularlighting.h +60 -0
- data/ext/mathematical/lsmsvgfiltersurface.c +455 -0
- data/ext/mathematical/lsmsvgfiltersurface.h +66 -0
- data/ext/mathematical/lsmsvgfiltertile.c +102 -0
- data/ext/mathematical/lsmsvgfiltertile.h +57 -0
- data/ext/mathematical/lsmsvggelement.c +73 -0
- data/ext/mathematical/lsmsvggelement.h +55 -0
- data/ext/mathematical/lsmsvggradientelement.c +151 -0
- data/ext/mathematical/lsmsvggradientelement.h +68 -0
- data/ext/mathematical/lsmsvgimageelement.c +261 -0
- data/ext/mathematical/lsmsvgimageelement.h +67 -0
- data/ext/mathematical/lsmsvglength.c +152 -0
- data/ext/mathematical/lsmsvglength.h +65 -0
- data/ext/mathematical/lsmsvglineargradientelement.c +271 -0
- data/ext/mathematical/lsmsvglineargradientelement.h +60 -0
- data/ext/mathematical/lsmsvglineelement.c +153 -0
- data/ext/mathematical/lsmsvglineelement.h +60 -0
- data/ext/mathematical/lsmsvgmarkerelement.c +266 -0
- data/ext/mathematical/lsmsvgmarkerelement.h +74 -0
- data/ext/mathematical/lsmsvgmaskelement.c +232 -0
- data/ext/mathematical/lsmsvgmaskelement.h +64 -0
- data/ext/mathematical/lsmsvgmatrix.c +205 -0
- data/ext/mathematical/lsmsvgmatrix.h +59 -0
- data/ext/mathematical/lsmsvgpathelement.c +115 -0
- data/ext/mathematical/lsmsvgpathelement.h +59 -0
- data/ext/mathematical/lsmsvgpatternelement.c +398 -0
- data/ext/mathematical/lsmsvgpatternelement.h +69 -0
- data/ext/mathematical/lsmsvgpolygonelement.c +106 -0
- data/ext/mathematical/lsmsvgpolygonelement.h +57 -0
- data/ext/mathematical/lsmsvgpolylineelement.c +106 -0
- data/ext/mathematical/lsmsvgpolylineelement.h +57 -0
- data/ext/mathematical/lsmsvgradialgradientelement.c +323 -0
- data/ext/mathematical/lsmsvgradialgradientelement.h +61 -0
- data/ext/mathematical/lsmsvgrectelement.c +184 -0
- data/ext/mathematical/lsmsvgrectelement.h +62 -0
- data/ext/mathematical/lsmsvgstopelement.c +106 -0
- data/ext/mathematical/lsmsvgstopelement.h +57 -0
- data/ext/mathematical/lsmsvgstyle.c +560 -0
- data/ext/mathematical/lsmsvgstyle.h +217 -0
- data/ext/mathematical/lsmsvgsvgelement.c +260 -0
- data/ext/mathematical/lsmsvgsvgelement.h +71 -0
- data/ext/mathematical/lsmsvgswitchelement.c +103 -0
- data/ext/mathematical/lsmsvgswitchelement.h +55 -0
- data/ext/mathematical/lsmsvgsymbolelement.c +74 -0
- data/ext/mathematical/lsmsvgsymbolelement.h +55 -0
- data/ext/mathematical/lsmsvgtextelement.c +203 -0
- data/ext/mathematical/lsmsvgtextelement.h +60 -0
- data/ext/mathematical/lsmsvgtraits.c +1232 -0
- data/ext/mathematical/lsmsvgtraits.h +104 -0
- data/ext/mathematical/lsmsvgtransformable.c +106 -0
- data/ext/mathematical/lsmsvgtransformable.h +54 -0
- data/ext/mathematical/lsmsvgtspanelement.c +174 -0
- data/ext/mathematical/lsmsvgtspanelement.h +60 -0
- data/ext/mathematical/lsmsvgtypes.h +77 -0
- data/ext/mathematical/lsmsvguseelement.c +237 -0
- data/ext/mathematical/lsmsvguseelement.h +69 -0
- data/ext/mathematical/lsmsvgview.c +2583 -0
- data/ext/mathematical/lsmsvgview.h +179 -0
- data/ext/mathematical/lsmtraits.c +119 -0
- data/ext/mathematical/lsmtraits.h +49 -0
- data/ext/mathematical/lsmtypes.h +36 -0
- data/ext/mathematical/lsmutils.c +54 -0
- data/ext/mathematical/lsmutils.h +56 -0
- data/ext/mathematical/mathematical.c +145 -0
- data/ext/mathematical/y.tab.c +6179 -0
- data/ext/mathematical/y.tab.h +389 -0
- data/lib/mathematical/version.rb +1 -1
- data/mathematical.gemspec +8 -6
- data/test/mathematical/basic_test.rb +9 -0
- data/test/mathematical/fixtures/after/brackets_display.html +1 -0
- data/test/mathematical/fixtures/after/compliance_accents.html +17 -0
- data/test/mathematical/fixtures/after/compliance_arrows.html +71 -0
- data/test/mathematical/fixtures/after/compliance_colors.html +4 -0
- data/test/mathematical/fixtures/after/compliance_greek_letters.html +42 -0
- data/test/mathematical/fixtures/after/compliance_large_math.html +19 -0
- data/test/mathematical/fixtures/after/compliance_log_symbols.html +34 -0
- data/test/mathematical/fixtures/after/compliance_operators.html +262 -0
- data/test/mathematical/fixtures/after/dollar_sign_inline.html +1 -0
- data/test/mathematical/fixtures/after/equation_display.html +1 -0
- data/test/mathematical/fixtures/after/multiple_dollar_inline.html +1 -0
- data/test/mathematical/fixtures/after/parens_inline.html +1 -0
- data/test/mathematical/fixtures/before/brackets_display.text +1 -0
- data/test/mathematical/fixtures/before/compliance_accents.text +17 -0
- data/test/mathematical/fixtures/before/compliance_arrows.text +71 -0
- data/test/mathematical/fixtures/before/compliance_colors.text +4 -0
- data/test/mathematical/fixtures/before/compliance_greek_letters.text +42 -0
- data/test/mathematical/fixtures/before/compliance_large_math.text +19 -0
- data/test/mathematical/fixtures/before/compliance_log_symbols.text +34 -0
- data/test/mathematical/fixtures/before/compliance_operators.text +262 -0
- data/test/mathematical/fixtures/before/dollar_sign_inline.text +1 -0
- data/test/mathematical/fixtures/before/equation_display.text +1 -0
- data/test/mathematical/fixtures/before/multiple_dollar_inline.text +1 -0
- data/test/mathematical/fixtures/before/parens_inline.text +1 -0
- data/test/mathematical/fixtures/performance/big_file.text +1767 -0
- data/test/mathematical/fixtures_test.rb +45 -0
- data/test/mathematical/maliciousness_test.rb +45 -0
- data/test/mathematical/performance_test.rb +15 -0
- data/test/test_helper.rb +5 -0
- metadata +301 -14
- data/lib/mathematical.bundle +0 -0
- data/lib/mathematical/mathematical.bundle +0 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2007-2010 Emmanuel Pacaud
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General
|
16
|
+
* Public License along with this library; if not, write to the
|
17
|
+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
+
* Boston, MA 02111-1307, USA.
|
19
|
+
*
|
20
|
+
* Author:
|
21
|
+
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
#ifndef LSM_DOM_CHARACTER_DATA_H
|
25
|
+
#define LSM_DOM_CHARACTER_DATA_H
|
26
|
+
|
27
|
+
#include <lsmdomnode.h>
|
28
|
+
|
29
|
+
G_BEGIN_DECLS
|
30
|
+
|
31
|
+
#define LSM_TYPE_DOM_CHARACTER_DATA (lsm_dom_character_data_get_type ())
|
32
|
+
#define LSM_DOM_CHARACTER_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_DOM_CHARACTER_DATA, LsmDomCharacterData))
|
33
|
+
#define LSM_DOM_CHARACTER_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_DOM_CHARACTER_DATA, LsmDomNodeClass))
|
34
|
+
#define LSM_IS_DOM_CHARACTER_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_DOM_CHARACTER_DATA))
|
35
|
+
#define LSM_IS_DOM_CHARACTER_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_DOM_CHARACTER_DATA))
|
36
|
+
#define LSM_DOM_CHARACTER_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_DOM_CHARACTER_DATA, LsmDomCharacterDataClass))
|
37
|
+
|
38
|
+
typedef struct _LsmDomCharacterDataClass LsmDomCharacterDataClass;
|
39
|
+
|
40
|
+
struct _LsmDomCharacterData
|
41
|
+
{
|
42
|
+
LsmDomNode node;
|
43
|
+
|
44
|
+
char *data;
|
45
|
+
};
|
46
|
+
|
47
|
+
struct _LsmDomCharacterDataClass {
|
48
|
+
LsmDomNodeClass parent_class;
|
49
|
+
};
|
50
|
+
|
51
|
+
GType lsm_dom_character_data_get_type (void);
|
52
|
+
|
53
|
+
const char * lsm_dom_character_data_get_data (LsmDomCharacterData* self);
|
54
|
+
void lsm_dom_character_data_set_data (LsmDomCharacterData* self, const char* value);
|
55
|
+
|
56
|
+
G_END_DECLS
|
57
|
+
|
58
|
+
#endif
|
59
|
+
|
@@ -0,0 +1,255 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2007-2010 Emmanuel Pacaud
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General
|
16
|
+
* Public License along with this library; if not, write to the
|
17
|
+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
+
* Boston, MA 02111-1307, USA.
|
19
|
+
*
|
20
|
+
* Author:
|
21
|
+
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
/**
|
25
|
+
* SECTION:lsmdomdocument
|
26
|
+
* @short_description: Base class for DOM document nodes
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include <lsmdomdocument.h>
|
30
|
+
#include <lsmdomelement.h>
|
31
|
+
#include <lsmstr.h>
|
32
|
+
#include <lsmdebug.h>
|
33
|
+
#include <lsmdomtext.h>
|
34
|
+
#include <gio/gio.h>
|
35
|
+
#include <string.h>
|
36
|
+
|
37
|
+
static GObjectClass *parent_class;
|
38
|
+
|
39
|
+
/* LsmDomNode implementation */
|
40
|
+
|
41
|
+
static const char *
|
42
|
+
lsm_dom_document_get_node_name (LsmDomNode *node)
|
43
|
+
{
|
44
|
+
return "#document";
|
45
|
+
}
|
46
|
+
|
47
|
+
static LsmDomNodeType
|
48
|
+
lsm_dom_document_get_node_type (LsmDomNode *node)
|
49
|
+
{
|
50
|
+
return LSM_DOM_NODE_TYPE_DOCUMENT_NODE;
|
51
|
+
}
|
52
|
+
|
53
|
+
/* LsmDomDocument implementation */
|
54
|
+
|
55
|
+
|
56
|
+
/**
|
57
|
+
* lsm_dom_document_get_document_element:
|
58
|
+
* @self: a #LsmDomElement
|
59
|
+
*
|
60
|
+
* Returns: (transfer none): document element
|
61
|
+
*/
|
62
|
+
|
63
|
+
LsmDomElement *
|
64
|
+
lsm_dom_document_get_document_element (LsmDomDocument *self)
|
65
|
+
{
|
66
|
+
g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (self), NULL);
|
67
|
+
|
68
|
+
return LSM_DOM_ELEMENT (lsm_dom_node_get_first_child (LSM_DOM_NODE (self)));
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* lsm_dom_document_create_element:
|
73
|
+
* @self: a #LsmDomDocument
|
74
|
+
* @tag_name: name of the element to create
|
75
|
+
*
|
76
|
+
* Returns: (transfer full): a newly created #LsmDomElement
|
77
|
+
*/
|
78
|
+
|
79
|
+
LsmDomElement *
|
80
|
+
lsm_dom_document_create_element (LsmDomDocument *document, const char *tag_name)
|
81
|
+
{
|
82
|
+
LsmDomDocumentClass *document_class;
|
83
|
+
LsmDomElement *element;
|
84
|
+
|
85
|
+
g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (document), NULL);
|
86
|
+
|
87
|
+
document_class = LSM_DOM_DOCUMENT_GET_CLASS (document);
|
88
|
+
if (document_class->create_element == NULL)
|
89
|
+
return NULL;
|
90
|
+
|
91
|
+
element = document_class->create_element (document, tag_name);
|
92
|
+
if (element != NULL)
|
93
|
+
LSM_DOM_NODE (element)->owner_document = document;
|
94
|
+
|
95
|
+
return element;
|
96
|
+
}
|
97
|
+
|
98
|
+
static LsmDomText *
|
99
|
+
lsm_dom_document_create_text_node_base (LsmDomDocument *document, const char *data)
|
100
|
+
{
|
101
|
+
LsmDomText *text_node;
|
102
|
+
|
103
|
+
text_node = LSM_DOM_TEXT (lsm_dom_text_new (data));
|
104
|
+
|
105
|
+
if (text_node != NULL)
|
106
|
+
LSM_DOM_NODE (text_node)->owner_document = document;
|
107
|
+
|
108
|
+
return text_node;
|
109
|
+
}
|
110
|
+
|
111
|
+
/**
|
112
|
+
* lsm_dom_document_create_text_node:
|
113
|
+
* @self: a #LsmDomDocument
|
114
|
+
* @data: content of the text node
|
115
|
+
*
|
116
|
+
* Returns: (transfer full): a newly created #LsmDomText
|
117
|
+
*/
|
118
|
+
|
119
|
+
LsmDomText *
|
120
|
+
lsm_dom_document_create_text_node (LsmDomDocument *document, const char *data)
|
121
|
+
{
|
122
|
+
g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (document), NULL);
|
123
|
+
|
124
|
+
return LSM_DOM_DOCUMENT_GET_CLASS (document)->create_text_node (document, data);
|
125
|
+
}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* lsm_dom_document_create_view:
|
129
|
+
* @self: a #LsmDomDocument
|
130
|
+
*
|
131
|
+
* Returns: (transfer full): a new #LsmDomView
|
132
|
+
*/
|
133
|
+
|
134
|
+
LsmDomView *
|
135
|
+
lsm_dom_document_create_view (LsmDomDocument *self)
|
136
|
+
{
|
137
|
+
g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (self), NULL);
|
138
|
+
|
139
|
+
return LSM_DOM_DOCUMENT_GET_CLASS (self)->create_view (self);
|
140
|
+
}
|
141
|
+
|
142
|
+
const char *
|
143
|
+
lsm_dom_document_get_url (LsmDomDocument *self)
|
144
|
+
{
|
145
|
+
g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (self), NULL);
|
146
|
+
|
147
|
+
return self->url;
|
148
|
+
}
|
149
|
+
|
150
|
+
void
|
151
|
+
lsm_dom_document_set_path (LsmDomDocument *self, const char *path)
|
152
|
+
{
|
153
|
+
g_return_if_fail (LSM_IS_DOM_DOCUMENT (self));
|
154
|
+
|
155
|
+
g_free (self->url);
|
156
|
+
|
157
|
+
if (path == NULL) {
|
158
|
+
self->url = NULL;
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
|
162
|
+
self->url = lsm_str_to_uri (path);
|
163
|
+
}
|
164
|
+
|
165
|
+
void
|
166
|
+
lsm_dom_document_set_url (LsmDomDocument *self, const char *url)
|
167
|
+
{
|
168
|
+
g_return_if_fail (LSM_IS_DOM_DOCUMENT (self));
|
169
|
+
g_return_if_fail (url == NULL || lsm_str_is_uri (url));
|
170
|
+
|
171
|
+
g_free (self->url);
|
172
|
+
self->url = g_strdup (url);
|
173
|
+
}
|
174
|
+
|
175
|
+
/**
|
176
|
+
* lsm_dom_document_get_href_data:
|
177
|
+
* @self: a #LsmDomDocument
|
178
|
+
* @href: href
|
179
|
+
* @size: placeholder for the size of the returned data
|
180
|
+
*
|
181
|
+
* Returns: (transfer full): a newly allocated buffer containing the requested data.
|
182
|
+
*/
|
183
|
+
|
184
|
+
void *
|
185
|
+
lsm_dom_document_get_href_data (LsmDomDocument *self, const char *href, gsize *size)
|
186
|
+
{
|
187
|
+
GFile *file;
|
188
|
+
char *data = NULL;
|
189
|
+
|
190
|
+
g_return_val_if_fail (LSM_IS_DOM_DOCUMENT (self), NULL);
|
191
|
+
g_return_val_if_fail (href != NULL, NULL);
|
192
|
+
|
193
|
+
if (strncmp (href, "data:", 5) == 0) {
|
194
|
+
while (*href != '\0' && *href != ',')
|
195
|
+
href++;
|
196
|
+
return g_base64_decode (href, size);
|
197
|
+
}
|
198
|
+
|
199
|
+
file = g_file_new_for_uri (href);
|
200
|
+
|
201
|
+
if (!g_file_load_contents (file, NULL, &data, size, NULL, NULL) && self->url != NULL) {
|
202
|
+
GFile *document_file;
|
203
|
+
GFile *parent_file;
|
204
|
+
|
205
|
+
g_object_unref (file);
|
206
|
+
|
207
|
+
document_file = g_file_new_for_uri (self->url);
|
208
|
+
parent_file = g_file_get_parent (document_file);
|
209
|
+
file = g_file_resolve_relative_path (parent_file, href);
|
210
|
+
g_object_unref (document_file);
|
211
|
+
g_object_unref (parent_file);
|
212
|
+
|
213
|
+
g_file_load_contents (file, NULL, &data, size, NULL, NULL);
|
214
|
+
}
|
215
|
+
|
216
|
+
g_object_unref (file);
|
217
|
+
|
218
|
+
return data;
|
219
|
+
}
|
220
|
+
|
221
|
+
static void
|
222
|
+
lsm_dom_document_init (LsmDomDocument *document)
|
223
|
+
{
|
224
|
+
}
|
225
|
+
|
226
|
+
static void
|
227
|
+
lsm_dom_document_finalize (GObject *object)
|
228
|
+
{
|
229
|
+
LsmDomDocument *document = LSM_DOM_DOCUMENT (object);
|
230
|
+
|
231
|
+
g_free (document->url);
|
232
|
+
|
233
|
+
parent_class->finalize (object);
|
234
|
+
}
|
235
|
+
|
236
|
+
/* LsmDomDocument class */
|
237
|
+
|
238
|
+
static void
|
239
|
+
lsm_dom_document_class_init (LsmDomDocumentClass *klass)
|
240
|
+
{
|
241
|
+
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
242
|
+
LsmDomNodeClass *node_class = LSM_DOM_NODE_CLASS (klass);
|
243
|
+
|
244
|
+
parent_class = g_type_class_peek_parent (klass);
|
245
|
+
|
246
|
+
object_class->finalize = lsm_dom_document_finalize;
|
247
|
+
|
248
|
+
node_class->get_node_name = lsm_dom_document_get_node_name;
|
249
|
+
node_class->get_node_type = lsm_dom_document_get_node_type;
|
250
|
+
|
251
|
+
klass->create_text_node = lsm_dom_document_create_text_node_base;
|
252
|
+
}
|
253
|
+
|
254
|
+
G_DEFINE_ABSTRACT_TYPE (LsmDomDocument, lsm_dom_document, LSM_TYPE_DOM_NODE)
|
255
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2007-2008 Emmanuel Pacaud
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General
|
16
|
+
* Public License along with this library; if not, write to the
|
17
|
+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
+
* Boston, MA 02111-1307, USA.
|
19
|
+
*
|
20
|
+
* Author:
|
21
|
+
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
#ifndef LSM_DOM_DOCUMENT_H
|
25
|
+
#define LSM_DOM_DOCUMENT_H
|
26
|
+
|
27
|
+
#include <lsmtypes.h>
|
28
|
+
#include <lsmdomtypes.h>
|
29
|
+
#include <lsmdomnode.h>
|
30
|
+
#include <lsmdomview.h>
|
31
|
+
|
32
|
+
G_BEGIN_DECLS
|
33
|
+
|
34
|
+
#define LSM_TYPE_DOM_DOCUMENT (lsm_dom_document_get_type ())
|
35
|
+
#define LSM_DOM_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_DOM_DOCUMENT, LsmDomDocument))
|
36
|
+
#define LSM_DOM_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_DOM_DOCUMENT, LsmDomDocumentClass))
|
37
|
+
#define LSM_IS_DOM_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_DOM_DOCUMENT))
|
38
|
+
#define LSM_IS_DOM_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_DOM_DOCUMENT))
|
39
|
+
#define LSM_DOM_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_DOM_DOCUMENT, LsmDomDocumentClass))
|
40
|
+
|
41
|
+
typedef struct _LsmDomDocumentClass LsmDomDocumentClass;
|
42
|
+
|
43
|
+
struct _LsmDomDocument {
|
44
|
+
LsmDomNode node;
|
45
|
+
|
46
|
+
char * url;
|
47
|
+
};
|
48
|
+
|
49
|
+
struct _LsmDomDocumentClass {
|
50
|
+
LsmDomNodeClass parent_class;
|
51
|
+
|
52
|
+
LsmDomElement * (*get_document_element) (LsmDomDocument* self);
|
53
|
+
LsmDomElement * (*create_element) (LsmDomDocument* self, const char *tag_name);
|
54
|
+
LsmDomText * (*create_text_node) (LsmDomDocument* self, const char *data);
|
55
|
+
|
56
|
+
LsmDomView* (*create_view) (LsmDomDocument *self);
|
57
|
+
};
|
58
|
+
|
59
|
+
GType lsm_dom_document_get_type (void);
|
60
|
+
|
61
|
+
LsmDomElement* lsm_dom_document_get_document_element (LsmDomDocument* self);
|
62
|
+
LsmDomElement* lsm_dom_document_create_element (LsmDomDocument* self, const char *tag_name);
|
63
|
+
LsmDomText* lsm_dom_document_create_text_node (LsmDomDocument* self, const char *data);
|
64
|
+
|
65
|
+
LsmDomView* lsm_dom_document_create_view (LsmDomDocument *self);
|
66
|
+
|
67
|
+
const char * lsm_dom_document_get_url (LsmDomDocument *self);
|
68
|
+
void lsm_dom_document_set_url (LsmDomDocument *self, const char *url);
|
69
|
+
void lsm_dom_document_set_path (LsmDomDocument *self, const char *path);
|
70
|
+
|
71
|
+
void * lsm_dom_document_get_href_data (LsmDomDocument *self, const char *href, gsize *size);
|
72
|
+
|
73
|
+
G_END_DECLS
|
74
|
+
|
75
|
+
#endif
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/* Lasem
|
2
|
+
*
|
3
|
+
* Copyright © 2010 Emmanuel Pacaud
|
4
|
+
*
|
5
|
+
* This library is free software; you can redistribute it and/or
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
7
|
+
* License as published by the Free Software Foundation; either
|
8
|
+
* version 2 of the License, or (at your option) any later version.
|
9
|
+
*
|
10
|
+
* This library is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
* Lesser General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU Lesser General
|
16
|
+
* Public License along with this library; if not, write to the
|
17
|
+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18
|
+
* Boston, MA 02111-1307, USA.
|
19
|
+
*
|
20
|
+
* Author:
|
21
|
+
* Emmanuel Pacaud <emmanuel@gnome.org>
|
22
|
+
*/
|
23
|
+
|
24
|
+
/**
|
25
|
+
* SECTION:lsmdomdocumentfragment
|
26
|
+
* @short_description: Base class for DOM document fragments
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include <lsmdomdocumentfragment.h>
|
30
|
+
#include <string.h>
|
31
|
+
|
32
|
+
static GObjectClass *parent_class = NULL;
|
33
|
+
|
34
|
+
/* LsmDomNode implementation */
|
35
|
+
|
36
|
+
static const char *
|
37
|
+
lsm_dom_document_fragment_get_node_name (LsmDomNode *node)
|
38
|
+
{
|
39
|
+
return "#document-fragment";
|
40
|
+
}
|
41
|
+
|
42
|
+
static const char *
|
43
|
+
lsm_dom_document_fragment_get_node_value (LsmDomNode *node)
|
44
|
+
{
|
45
|
+
return NULL;
|
46
|
+
}
|
47
|
+
|
48
|
+
static LsmDomNodeType
|
49
|
+
lsm_dom_document_fragment_get_node_type (LsmDomNode *node)
|
50
|
+
{
|
51
|
+
return LSM_DOM_NODE_TYPE_DOCUMENT_FRAGMENT_NODE;
|
52
|
+
}
|
53
|
+
|
54
|
+
/* LsmDomDocumentFragment implementation */
|
55
|
+
|
56
|
+
LsmDomDocumentFragment *
|
57
|
+
lsm_dom_document_fragment_new (void)
|
58
|
+
{
|
59
|
+
return g_object_new (LSM_TYPE_DOM_DOCUMENT_FRAGMENT, NULL);
|
60
|
+
}
|
61
|
+
|
62
|
+
static void
|
63
|
+
lsm_dom_document_fragment_init (LsmDomDocumentFragment *document_fragment)
|
64
|
+
{
|
65
|
+
}
|
66
|
+
|
67
|
+
/* LsmDomDocumentFragment class */
|
68
|
+
|
69
|
+
static void
|
70
|
+
lsm_dom_document_fragment_class_init (LsmDomDocumentFragmentClass *klass)
|
71
|
+
{
|
72
|
+
LsmDomNodeClass *node_class = LSM_DOM_NODE_CLASS (klass);
|
73
|
+
|
74
|
+
parent_class = g_type_class_peek_parent (klass);
|
75
|
+
|
76
|
+
node_class->get_node_name = lsm_dom_document_fragment_get_node_name;
|
77
|
+
node_class->get_node_value = lsm_dom_document_fragment_get_node_value;
|
78
|
+
node_class->get_node_type = lsm_dom_document_fragment_get_node_type;
|
79
|
+
}
|
80
|
+
|
81
|
+
G_DEFINE_ABSTRACT_TYPE (LsmDomDocumentFragment, lsm_dom_document_fragment, LSM_TYPE_DOM_NODE)
|