Skip to content

Commit

Permalink
Fix export with pandoc
Browse files Browse the repository at this point in the history
issue #6
  • Loading branch information
maoschanz committed Jan 19, 2020
1 parent 4bbad93 commit 2da539f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

<!-- TODO
- checkboxs individuelles pour les sous-extensions de "extra" ? https://python-markdown.github.io/extensions/
- help labels and links for pandoc too!
- CSS for admonitions
- cesser les zouaveries avec pandoc et les pre-strings/post-strings, il y a de vraies options
- compléter les descriptions des schémas
- se souvenir du splitter
- ajouter le réglage pour le splitter dans les préférences
- ajouter le réglage pour la position dans les préférences
- utiliser encore + le même UI pour le backend dans export.py et dans prefs.py
- factoriser des trucs de export.py et de prefs.py
- interdire le redimensionnement de l'entrée de texte quand on change le format
TODO -->
- [ ] checkboxs individuelles pour les sous-extensions de "extra" ? https://python-markdown.github.io/extensions/
- [ ] help labels and links for pandoc too!
- [ ] CSS for admonitions
- [ ] cesser les zouaveries avec pandoc et les pre-strings/post-strings, il y a de vraies options
- [ ] compléter les descriptions des schémas
- [ ] se souvenir du splitter
- [ ] ajouter le réglage pour le splitter dans les préférences
~ TODO -->

This is a plugin for the Gedit text editor, previewing .md files in the side (`F9`) or the bottom (`Ctrl+F9`) panel.

Expand Down
12 changes: 7 additions & 5 deletions markdown_preview/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,21 @@ def __init__(self, file_format, gedit_window, settings, **kwargs):
self.file_format = file_format
self.gedit_window = gedit_window
self._settings = settings
self.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)
self.add_button(_("Next"), Gtk.ResponseType.OK)

self.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)
self.get_content_area().set_margin_left(20)
self.get_content_area().set_margin_right(20)
self.get_content_area().set_margin_top(20)
self.get_content_area().set_margin_bottom(20)
self.get_content_area().set_spacing(20)

if not BACKEND_P3MD_AVAILABLE and not BACKEND_PANDOC_AVAILABLE:
error_label = Gtk.Label(visible=True, \
label=_("Error: please install pandoc or python3-markdown"))
self.get_content_area().add(error_label)
return
self.add_button(_("Next"), Gtk.ResponseType.OK)

# Add the backend settings to the dialog
self._backend = MdBackendSettings(_("Export file with:"), \
self._settings, False)
self.get_content_area().add(self._backend.full_widget)
Expand Down Expand Up @@ -356,6 +356,7 @@ def launch_file_chooser(self, output_extension):
# retirer l'ancienne extension ?
name = str(name + ' ' + _("(exported)") + output_extension)
file_chooser.set_current_name(name)
file_chooser.set_do_overwrite_confirmation(True)
response = file_chooser.run()
if response == Gtk.ResponseType.ACCEPT:
return file_chooser
Expand All @@ -369,7 +370,7 @@ def export_p3md(self):
return False

md_extensions = []
for plugin_id in P3MD_PLUGINS:
for plugin_id in self._backend.plugins:
if self._backend.plugins[plugin_id].get_active():
md_extensions.append(plugin_id)

Expand Down Expand Up @@ -400,7 +401,8 @@ def export_pandoc(self):

output_format = self._backend.format_combobox.get_active_id()
doc_path = self.gedit_window.get_active_document().get_location().get_path()
cmd = self._backend.pandoc_cli_entry.get_buffer().get_text()
buff = self._backend.pandoc_cli_entry.get_buffer()
cmd = buff.get_text(buff.get_start_iter(), buff.get_end_iter(), False)
words = cmd.split()
words[words.index('$INPUT_FILE')] = doc_path
words[words.index('$OUTPUT_FILE')] = file_chooser.get_filename()
Expand Down

0 comments on commit 2da539f

Please sign in to comment.