1 # -*- python; coding: utf-8 -*-
3 # gtk-doc - GTK DocBook documentation generator.
4 # Copyright (C) 2015 Christoph Reiter
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 from gtkdoc
import md_to_db
27 class TestConverter(unittest
.TestCase
):
53 Ordered (unnested) Lists
54 ------------------------
58 1. item 2 with loooong *foo*
63 Note: we require a blank line above the list items
67 <para>SUPPORTED MARKDOWN</para>
68 <para>Atx-style Headers</para>
69 <refsect2><title>Header 1</title><refsect3><title>Header 2</title></refsect3>
70 <refsect3><title>Setext-style Headers</title></refsect3>
72 <refsect2><title>Header 1</title><para>Header 2</para>
73 <para>Ordered (unnested) Lists</para>
79 <para>item 2 with loooong *foo*
86 <para>Note: we require a blank line above the list items</para>
90 output
= md_to_db
.MarkDownParse(input_
, "")
91 self
.assertEqual(expexted
, output
)
93 def test_docbook(self
):
96 <listitem><para>foo</para></listitem>
100 # docbook should stay the same
101 output
= md_to_db
.MarkDownParse(input_
, "")
102 self
.assertEqual(input_
, output
)
104 def test_header(self
):
106 widget lifecycle, states and style.
108 # Height-for-width Geometry Management # {#geometry-management}
110 GTK+ uses a height-for-width (and wid
114 <para>widget lifecycle, states and style.</para>
115 <refsect2 id="geometry-management"><title>Height-for-width Geometry Management</title><para>GTK+ uses a height-for-width (and wid</para>
119 output
= md_to_db
.MarkDownParse(input_
, "")
120 self
.assertEqual(expected
, output
)
122 def test_lists(self
):
127 - The channel was just created, and has not been written to or read from yet.
130 - The channel is write-only.
139 <para>The channel was just created, and has not been written to or read from yet.
143 <para>The channel is write-only.</para>
148 output
= md_to_db
.MarkDownParse(input_
, "")
149 self
.assertEqual(expected
, output
)
151 def test_paragraphs(self
):
170 output
= md_to_db
.MarkDownParse(input_
, "")
171 self
.assertEqual(expected
, output
)
173 def test_reference(self
):
175 The #GData struct is an opaque data structure to represent a
176 [Keyed Data List][glib-Keyed-Data-Lists]. It should only be
177 accessed via the following functions."""
180 <para>The <link linkend="GData"><type>GData</type></link> struct is an opaque data structure to represent a
181 <link linkend="glib-Keyed-Data-Lists">Keyed Data List</link>. It should only be
182 accessed via the following functions.</para>
185 output
= md_to_db
.MarkDownParse(input_
, "")
186 self
.assertEqual(expected
, output
)
188 def test_reference2(self
):
189 input_
= "a [foo][bar] b [quux][baz]"
190 expected
= '<para>a <link linkend="bar">foo</link> b <link linkend="baz">quux</link></para>\n'
191 output
= md_to_db
.MarkDownParse(input_
, "")
192 self
.assertEqual(expected
, output
)
194 def test_reference_empty(self
):
196 # expected = '<para><ulink url=""></ulink></para>\n'
197 expected
= '<para><link linkend=""></link></para>\n'
198 output
= md_to_db
.MarkDownParse(input_
, "")
199 self
.assertEqual(expected
, output
)
201 def test_inline_code(self
):
203 expected
= '<para>a <literal>abc</literal></para>\n'
204 output
= md_to_db
.MarkDownParse(input_
, "")
205 self
.assertEqual(expected
, output
)
207 def test_inline_code2(self
):
209 expected
= '<para>a <literal>[][]</literal></para>\n'
210 output
= md_to_db
.MarkDownParse(input_
, "")
211 self
.assertEqual(expected
, output
)
213 def test_verbatim(self
):
214 input_
= "a `<child>` element"
215 expected
= '<para>a <literal><child></literal> element</para>\n'
216 output
= md_to_db
.MarkDownParse(input_
, "")
217 self
.assertEqual(expected
, output
)
221 |[<!-- language="C" -->
230 <informalexample><programlisting role="example" language="C"><![CDATA[
235 ]]></programlisting></informalexample>
238 output
= md_to_db
.MarkDownParse(input_
, "")
239 self
.assertEqual(expected
, output
)
241 def test_plain(self
):
243 |[<!-- language="plain" -->
252 <informalexample><screen><![CDATA[
257 ]]></screen></informalexample>
261 output
= md_to_db
.MarkDownParse(input_
, "")
262 self
.assertEqual(expected
, output
)
265 if __name__
== '__main__':