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
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
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))
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
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))
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&b'), (r'a&b', 'a&b'), (r'http://site/s.php?q&c', 'http://site/s.php?q&c'), (r'http://site/s.php?q&c', 'http://site/s.php?q&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 '&' in t2t_markup: assert convert_from_pango(pango) == t2t_markup
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&b'), (r'a&b', 'a&b'), (r'http://site/s.php?q&c', 'http://site/s.php?q&c'), (r'http://site/s.php?q&c', 'http://site/s.php?q&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 in t2t_markup: assert convert_from_pango(pango) == t2t_markup
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&b"), (r"a&b", "a&b"), (r"http://site/s.php?q&c", "http://site/s.php?q&c"), (r"http://site/s.php?q&c", "http://site/s.php?q&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 in t2t_markup: assert convert_from_pango(pango) == t2t_markup