示例#1
0
def test_pango(t2t_markup, expected):
    pango = convert_to_pango(t2t_markup)
    assert pango == expected
    # Ampersand escaping is only needed in sourcecode, so we do not try to
    # preserve the encoding
    if "&" not in t2t_markup:
        assert convert_from_pango(pango) == t2t_markup
示例#2
0
    def get_iter_value(self, iter):
        # Let the renderer use text not markup temporarily
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, 'text', 0)

        pango_markup = self.tree_store.get_value(iter, 0).decode('utf-8')

        # Reset the renderer to use markup
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, 'markup', 0)

        # We want to have txt2tags markup and not pango markup
        text = markup.convert_from_pango(pango_markup)
        return text
示例#3
0
    def on_editing_started(self, cell, editable, path):
        # Let the renderer use text not markup temporarily
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, 'text', 0)

        # Fetch the markup
        pango_markup = self.tree_store[path][0]

        # Tell the renderer NOT to use markup
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, 'markup', 0)

        # We want to show txt2tags markup and not pango markup
        editable.set_text(markup.convert_from_pango(pango_markup))
示例#4
0
    def get_iter_value(self, iter):
        # Let the renderer use text not markup temporarily
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, "text", 0)

        pango_markup = self.tree_store.get_value(iter, 0)

        # Reset the renderer to use markup
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, "markup", 0)

        # We want to have txt2tags markup and not pango markup
        text = markup.convert_from_pango(pango_markup)
        return text
示例#5
0
    def on_editing_started(self, cell, editable, path):
        # Let the renderer use text not markup temporarily
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, "text", 0)

        # Fetch the markup
        pango_markup = self.tree_store[path][0]

        # Tell the renderer NOT to use markup
        self.tvcolumn.clear_attributes(self.cell)
        self.tvcolumn.add_attribute(self.cell, "markup", 0)

        # We want to show txt2tags markup and not pango markup
        editable.set_text(markup.convert_from_pango(pango_markup))
示例#6
0
def test_pango():
    vals = ((r'--stricken--', '<s>stricken</s>'),
            (r'//italic//', '<i>italic</i>'),
            (r'--www.test.com--', '<s>www.test.com</s>'),
            # Linebreaks only on line ends
            (r'First\\Second', r'First\\Second'),
            (r'First\\', 'First\n'),
            (r'a&b', 'a&amp;b'),
            (r'a&amp;b', 'a&amp;b'),
            (r'http://site/s.php?q&c', 'http://site/s.php?q&amp;c'),
            (r'http://site/s.php?q&amp;c', 'http://site/s.php?q&amp;c'),
           )
    for t2t_markup, expected in vals:
        pango = convert_to_pango(t2t_markup)
        assert pango == expected
        # Ampersand escaping is only needed in sourcecode, so we do not try to
        # preserve the encoding
        if not '&amp;' in t2t_markup:
            assert convert_from_pango(pango) == t2t_markup
示例#7
0
def test_pango():
    vals = (
        (r'--stricken--', '<s>stricken</s>'),
        (r'//italic//', '<i>italic</i>'),
        (r'--www.test.com--', '<s>www.test.com</s>'),
        # Linebreaks only on line ends
        (r'First\\Second', r'First\\Second'),
        (r'First\\', 'First\n'),
        (r'a&b', 'a&amp;b'),
        (r'a&amp;b', 'a&amp;b'),
        (r'http://site/s.php?q&c', 'http://site/s.php?q&amp;c'),
        (r'http://site/s.php?q&amp;c', 'http://site/s.php?q&amp;c'),
    )
    for t2t_markup, expected in vals:
        pango = convert_to_pango(t2t_markup)
        assert pango == expected
        # Ampersand escaping is only needed in sourcecode, so we do not try to
        # preserve the encoding
        if '&amp;' not in t2t_markup:
            assert convert_from_pango(pango) == t2t_markup
示例#8
0
def test_pango():
    vals = (
        (r"--stricken--", "<s>stricken</s>"),
        (r"//italic//", "<i>italic</i>"),
        (r"--www.test.com--", "<s>www.test.com</s>"),
        # Linebreaks only on line ends
        (r"First\\Second", r"First\\Second"),
        (r"First\\", "First\n"),
        (r"a&b", "a&amp;b"),
        (r"a&amp;b", "a&amp;b"),
        (r"http://site/s.php?q&c", "http://site/s.php?q&amp;c"),
        (r"http://site/s.php?q&amp;c", "http://site/s.php?q&amp;c"),
    )
    for t2t_markup, expected in vals:
        pango = convert_to_pango(t2t_markup)
        assert pango == expected
        # Ampersand escaping is only needed in sourcecode, so we do not try to
        # preserve the encoding
        if "&amp;" not in t2t_markup:
            assert convert_from_pango(pango) == t2t_markup