Ejemplo n.º 1
0
    def update_description(self):
        # I have become GTK - Destroyer Of Children
        for child in self.description_box.get_children():
            child.destroy()

        id = self.item.get_id()
        fallback = self.item.get_description()
        desc = self.context.appsystem.get_description(id, fallback)

        plain = As.markup_convert(desc, As.MarkupConvertFormat.MARKDOWN)
        lines = []
        try:
            self.parser.consume(plain)
            lines = self.parser.emit()
        except Exception as e:
            print("Parsing error: {}".format(e))
            plain = As.markup_convert_simple(desc)
            lines = plain.split("\n")

        for line in lines:
            lab = Gtk.Label(line)
            lab.set_use_markup(True)
            lab.set_halign(Gtk.Align.START)
            lab.set_line_wrap(True)
            lab.set_property("xalign", 0.0)
            lab.set_property("margin", 2)
            lab.set_margin_bottom(4)
            self.description_box.pack_start(lab, False, False, 0)
            lab.show_all()
Ejemplo n.º 2
0
    def update_description(self):
        # I have become GTK - Destroyer Of Children
        for child in self.description_box.get_children():
            child.destroy()

        id = self.item.get_id()
        fallback = self.item.get_description()
        store = self.item.get_store()
        desc = self.context.appsystem.get_description(id, fallback, store)

        plain = As.markup_convert(desc, As.MarkupConvertFormat.MARKDOWN)
        lines = []
        try:
            self.parser.consume(plain)
            lines = self.parser.emit()
        except Exception as e:
            print("Parsing error: {}".format(e))
            plain = As.markup_convert_simple(desc)
            lines = plain.split("\n")

        for line in lines:
            lab = Gtk.Label(line)
            lab.set_use_markup(True)
            lab.set_halign(Gtk.Align.START)
            lab.set_line_wrap(True)
            lab.set_property("xalign", 0.0)
            lab.set_property("margin", 2)
            lab.set_margin_bottom(4)
            self.description_box.pack_start(lab, False, False, 0)
            lab.show_all()
Ejemplo n.º 3
0
 def render_plain(self, input_string):
     """ Render a plain version of the description, no markdown """
     plain = As.markup_convert(input_string, -1,
                               As.MarkupConvertFormat.SIMPLE)
     plain = plain.replace(""", "\"").replace("'", "'")
     return plain
Ejemplo n.º 4
0
def test_markup(desc):
    m = AS.markup_convert(desc, -1, AS.MarkupConvertFormat.SIMPLE)
    return m
Ejemplo n.º 5
0
 def render_plain(self, input_string):
     """ Render a plain version of the description, no markdown """
     plain = As.markup_convert(input_string, -1,
                               As.MarkupConvertFormat.SIMPLE)
     plain = plain.replace(""", "\"")
     return plain
Ejemplo n.º 6
0
def test_markup(desc):
    m = AS.markup_convert(desc, -1, AS.MarkupConvertFormat.SIMPLE)
    return m