コード例 #1
0
ファイル: __init__.py プロジェクト: big-jump/kernlog
def markdown(text,
             extensions = [],
             safe_mode = False,
             output_format = 'xhtml1'):
    """Convert a markdown string to HTML and return HTML as a unicode string.

    This is a shortcut function for `Markdown` class to cover the most
    basic use case.  It initializes an instance of Markdown, loads the
    necessary extensions and runs the parser on the given text.

    Keyword arguments:

    * text: Markdown formatted text as Unicode or ASCII string.
    * extensions: A list of extensions or extension names (may contain config args).
    * safe_mode: Disallow raw html.  One of "remove", "replace" or "escape".
    * output_format: Format of output. Supported formats are:
        * "xhtml1": Outputs XHTML 1.x. Default.
        * "xhtml": Outputs latest supported version of XHTML (currently XHTML 1.1).
        * "html4": Outputs HTML 4
        * "html": Outputs latest supported version of HTML (currently HTML 4).
        Note that it is suggested that the more specific formats ("xhtml1"
        and "html4") be used as "xhtml" or "html" may change in the future
        if it makes sense at that time.

    Returns: An HTML document as a string.

    """
    md = Markdown(extensions=load_extensions(extensions),
                  safe_mode=safe_mode,
                  output_format=output_format)
    return md.convert(text)
コード例 #2
0
ファイル: __init__.py プロジェクト: GunioRobot/cherryblogger
def markdown(text, extensions=[], safe_mode=False, output_format='xhtml1'):
    """Convert a markdown string to HTML and return HTML as a unicode string.

    This is a shortcut function for `Markdown` class to cover the most
    basic use case.  It initializes an instance of Markdown, loads the
    necessary extensions and runs the parser on the given text.

    Keyword arguments:

    * text: Markdown formatted text as Unicode or ASCII string.
    * extensions: A list of extensions or extension names (may contain config args).
    * safe_mode: Disallow raw html.  One of "remove", "replace" or "escape".
    * output_format: Format of output. Supported formats are:
        * "xhtml1": Outputs XHTML 1.x. Default.
        * "xhtml": Outputs latest supported version of XHTML (currently XHTML 1.1).
        * "html4": Outputs HTML 4
        * "html": Outputs latest supported version of HTML (currently HTML 4).
        Note that it is suggested that the more specific formats ("xhtml1"
        and "html4") be used as "xhtml" or "html" may change in the future
        if it makes sense at that time.

    Returns: An HTML document as a string.

    """
    md = Markdown(extensions=load_extensions(extensions),
                  safe_mode=safe_mode,
                  output_format=output_format)
    return md.convert(text)
コード例 #3
0
ファイル: __init__.py プロジェクト: big-jump/kernlog
def markdownFromFile(input = None,
                     output = None,
                     extensions = [],
                     encoding = None,
                     safe_mode = False,
                     output_format = 'xhtml1'):
    """Read markdown code from a file and write it to a file or a stream."""
    md = Markdown(extensions=load_extensions(extensions),
                  safe_mode=safe_mode,
                  output_format=output_format)
    md.convertFile(input, output, encoding)
コード例 #4
0
ファイル: __init__.py プロジェクト: GunioRobot/cherryblogger
def markdownFromFile(input=None,
                     output=None,
                     extensions=[],
                     encoding=None,
                     safe_mode=False,
                     output_format='xhtml1'):
    """Read markdown code from a file and write it to a file or a stream."""
    md = Markdown(extensions=load_extensions(extensions),
                  safe_mode=safe_mode,
                  output_format=output_format)
    md.convertFile(input, output, encoding)
コード例 #5
0
ファイル: app.py プロジェクト: MrPablozOne/Bakalarka_Kaira
                "<a href='http://verif.cs.vsb.cz/kaira'>http://verif.cs.vsb.cz/kaira</a>" \
                    .format(ptp.get_config("Main", "VERSION"))
        label.set_markup(line)
        label.set_justify(gtk.JUSTIFY_CENTER)
        self.window.add_tab(Tab("Welcome",
                                label,
                                has_close_button=False,
                                mainmenu_groups=("welcome",)))

    def import_project(self):
        filename = self.run_file_dialog("Import project", "open", "Project", "*.proj")
        if filename is None:
            return

        if filename[-5:] != ".proj":
            filename = filename + ".proj"
        loader.import_project(self.project, filename)

    def save_as_svg(self):
        tab = self.window.get_current_tab()
        filename = "net.svg"
        tab.widget.save_as_svg(filename)
        self.console_write("Net saved as '{0}'.\n".format(filename), "success")

if __name__ == "__main__":
    args = sys.argv[1:] # Remove "app.py"
    extensions.load_extensions()
    app = App(args)
    app.run()

コード例 #6
0
ファイル: app.py プロジェクト: MrPablozOne/kaira
                "<a href='http://verif.cs.vsb.cz/kaira'>http://verif.cs.vsb.cz/kaira</a>" \
                    .format(ptp.get_config("Main", "VERSION"))
        label.set_markup(line)
        label.set_justify(gtk.JUSTIFY_CENTER)
        self.window.add_tab(Tab("Welcome",
                                label,
                                has_close_button=False,
                                mainmenu_groups=("welcome",)))

    def import_project(self):
        filename = self.run_file_dialog("Import project", "open", "Project", "*.proj")
        if filename is None:
            return

        if filename[-5:] != ".proj":
            filename = filename + ".proj"
        loader.import_project(self.project, filename)

    def save_as_svg(self):
        tab = self.window.get_current_tab()
        filename = "net.svg"
        tab.widget.save_as_svg(filename)
        self.console_write("Net saved as '{0}'.\n".format(filename), "success")

if __name__ == "__main__":
    args = sys.argv[1:] # Remove "app.py"
    extensions.load_extensions()
    app = App(args)
    app.run()