Revert "Fix make check"
[vala-gnome.git] / libvaladoc / html / htmlmarkupwriter.vala
blob15ed9efd175c5723447d4b6ccec22507672a5e54
1 /* markupwriter.vala
3 * Copyright (C) 2008-2014 Florian Brosch, Didier Villevalois
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.1 of the License, or (at your option) any later version.
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.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
23 using GLib;
24 using Valadoc.Content;
26 public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter {
28 public MarkupWriter (FileStream stream, bool xml_declaration = true) {
29 // avoid broken implicit copy
30 unowned FileStream _stream = stream;
32 base ((str) => {
33 _stream.printf (str);
34 }, xml_declaration);
37 public MarkupWriter.builder (StringBuilder builder, bool xml_declaration = true) {
38 // avoid broken implicit copy
39 unowned StringBuilder _builder = builder;
41 base ((str) => {
42 _builder.append (str);
43 }, xml_declaration);
46 public MarkupWriter add_usemap (Charts.Chart chart) {
47 string? buf = (string?) chart.write_buffer ("cmapx");
48 if (buf != null) {
49 raw_text ("\n");
50 raw_text ((!) buf);
53 return this;
56 // edit
57 public MarkupWriter link (string url, string label, string? css_class = null) {
58 if (css_class == null) {
59 start_tag ("a", {"href", url});
60 } else {
61 start_tag ("a", {"href", url, "class", css_class});
64 text (label);
65 end_tag ("a");
66 return this;
69 public MarkupWriter image (string src, string? caption = null, string? css_class = null) {
70 if (css_class == null) {
71 simple_tag ("img", {"src", src, "alt", caption});
72 } else {
73 simple_tag ("img", {"src", src, "alt", caption, "class", css_class});
75 return this;
78 public MarkupWriter stylesheet_link (string url) {
79 simple_tag ("link", {"href", url, "rel", "stylesheet", "type", "text/css"});
80 return this;
83 public MarkupWriter javascript_link (string url) {
84 start_tag ("script", {"src", url, "type", "text/javascript"});
85 end_tag ("script");
86 return this;
89 protected override bool inline_element (string name) {
90 return name != "html"
91 && name != "head"
92 && name != "title"
93 && name != "meta"
94 && name != "link"
95 && name != "body"
96 && name != "div"
97 && name != "p"
98 && name != "table"
99 && name != "tr"
100 && name != "td"
101 && name != "ul"
102 && name != "ol"
103 && name != "li"
104 && name != "h1"
105 && name != "h2"
106 && name != "h3"
107 && name != "h4"
108 && name != "h5"
109 && name != "hr"
110 && name != "img";
113 protected override bool content_inline_element (string name) {
114 return name == "title"
115 || name == "meta"
116 || name == "p"
117 || name == "a"
118 || name == "h1"
119 || name == "h2"
120 || name == "h3"
121 || name == "h4"
122 || name == "h5"
123 || name == "li"
124 || name == "span"
125 || name == "code"
126 || name == "b"
127 || name == "i"
128 || name == "u"
129 || name == "stoke";