def export(self, export_type, text=""): """Export the given text using the specified format. For advanced export, this includes special flags for the enabled options. Keyword Arguments: text {str} -- Text to export (default: {""}) """ args = [] if export_type == "advanced": filename = self.adv_export_name.get_text() # TODO: use walrust operator output_uri = self.adv_export_folder.get_uri() if output_uri: output_dir = GLib.filename_from_uri(output_uri)[0] else: raise NotADirectoryError( _("A folder must be selected before proceeding")) basename = os.path.basename(filename) fmt = self.formats[self.format_field.get_active()] to = fmt["to"] ext = fmt["ext"] if self.builder.get_object("html5").get_active() and to == "html": to = "html5" if self.builder.get_object("smart").get_active(): to += "+smart" args.extend(self.get_advanced_arguments(to, ext)) else: args = ["--variable=papersize:a4"] filename = self.dialog.get_filename() if filename.endswith("." + export_type): filename = filename[:-len(export_type) - 1] output_dir = os.path.abspath(os.path.join(filename, os.path.pardir)) basename = os.path.basename(filename) to = export_type ext = export_type if export_type == "html": to = "html5" args.append("--self-contained") args.append("--css=%s" % Theme.get_current().web_css_path) args.append("--mathjax") args.append( "--lua-filter=%s" % helpers.get_script_path('relative_to_absolute.lua')) args.append("--lua-filter=%s" % helpers.get_script_path('task-list.lua')) helpers.pandoc_convert(text, to=to, args=args, outputfile="%s/%s.%s" % (output_dir, basename, ext))
def export(text, file, _format, args): """Export the given text using the specified format. For advanced export, this includes special flags for the enabled options. Keyword Arguments: text {str} -- Text to export (default: {""}) """ to = _format helpers.pandoc_convert(text, to=to, args=args, outputfile=file.get_path())
def copy_html_to_clipboard(self, _widget=None, _date=None): """Copies only html without headers etc. to Clipboard """ output = helpers.pandoc_convert(self.text_view.get_text()) clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_text(output, -1) clipboard.store()
def __do_convert(self): while True: while True: (text, callback, user_data) = self.queue.get() if text is None and callback is None: return if self.queue.empty(): break args = [ '--standalone', '--mathjax', '--css=' + Theme.get_current().web_css_path, '--lua-filter=' + helpers.get_media_path('/lua/relative_to_absolute.lua'), '--lua-filter=' + helpers.get_media_path('/lua/task-list.lua') ] text = helpers.pandoc_convert(text, to="html5", args=args) GLib.idle_add(callback, text, *user_data)