string = p.sub(r"\1\\frownie\2", string)
return string
+def transform_vspace(string):
+ """vspace"""
+ p = re.compile("^\s*--(.*)--\s*$")
+ string = p.sub(r"\n\\vspace{\1}\n", string)
+ return string
+
+def transform_vspacestar(string):
+ """vspace*"""
+ p = re.compile("^\s*--\*(.*)--\s*$")
+ string = p.sub(r"\n\\vspace*{\1}\n", string)
+ return string
def transform(string, state):
""" convert/transform one line in context of state"""
string = transform_h3_to_subsec(string, state)
string = transform_h2_to_sec(string, state)
string = transform_replace_headfoot(string, state)
-
+
string = transform_environments(string)
string = transform_columns(string)
string = transform_boldfont(string)
string = transform_footnotes(string)
string = transform_graphics(string)
string = transform_substitutions(string)
+ string = transform_vspacestar(string)
+ string = transform_vspace(string)
string = transform_itemenums(string, state)
</variablelist>
</refsect2>
+<refsect2><title>Layout</title>
+ <variablelist>
+ <varlistentry><term>--<replaceable>length</replaceable>--</term>
+ <listitem><para>when found at start of line, with nothing afterwards,
+ insert a \vspace{<replaceable>length</replaceable>} (vertical space of length
+ <replaceable>length</replaceable>)</para></listitem>
+ </varlistentry>
+ <varlistentry><term>--*<replaceable>length</replaceable>--</term>
+ <listitem><para>
+ same as above, but insert a \vspace* (a forced vspace)
+ </para></listitem>
+ </varlistentry>
+ </variablelist>
+</refsect2>
+
<refsect2><title>Substitutions</title>
<variablelist>
<varlistentry><term>--></term>
def test_columns(self):
self.assertEqual(transform('[[[6cm]]]', self.state), '\\column{6cm}')
+ def test_vspace(self):
+ self.assertEqual(transform('--3em--', self.state), '\n\\vspace{3em}\n')
+ self.assertEqual(transform('--3em--foo', self.state), '--3em--foo')
+ self.assertEqual(transform(' --3em-- ', self.state), '\n\\vspace{3em}\n')
+
+ def test_vspacestar(self):
+ self.assertEqual(transform('--*3em--', self.state), '\n\\vspace*{3em}\n')
+ self.assertEqual(transform('--*3em--foo', self.state), '--*3em--foo')
+ self.assertEqual(transform(' --*3em-- ', self.state), '\n\\vspace*{3em}\n')
+
+
class TestExpandCode(unittest.TestCase):
def test_search_escape_sequences_basic(self):
code = "System435.out.println(\"foo\");123System.ou12t.println234(\"foo\");System.23out.23456println(\"foo\");S237yst28em.out.pr18intln(\"foo\");"