Skip to content

Commit

Permalink
add pandoc markdown as export format and adjust test, fiduswriter/fid…
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed May 16, 2024
1 parent e7e4812 commit 62cd945
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fiduswriter/pandoc/static/js/modules/pandoc/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ export class EditorPandoc {
})
}
},
{
title: gettext("Pandoc Markdown"),
type: "action",
tooltip: gettext("Export the document to a Pandoc Markdown file using pandoc."),
order: 1,
action: editor => {
import("./exporter").then(({PandocConversionExporter}) => {
const exporter = new PandocConversionExporter(
"markdown",
"md",
"text/markdown",
{includeBibliography: true},
editor.getDoc({changes: "acceptAllNoInsertions"}),
editor.mod.db.bibDB,
editor.mod.db.imageDB,
editor.app.csl,
editor.docInfo.updated
)
exporter.init()
})
}
},
{
title: gettext("PHP Markdown Extra"),
type: "action",
Expand Down
17 changes: 17 additions & 0 deletions fiduswriter/pandoc/tests/test_pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,31 @@ def test_export(self):
# Document with many features has been created let's see if we can
# export it from the editor.

# Export as Markdown
self.driver.find_element(
By.CSS_SELECTOR,
'.header-nav-item[title="Export of the document contents"]',
).click()
self.driver.find_element(
By.XPATH, '//*[normalize-space()="Markdown"]'
).click()
self.driver.find_element(
By.XPATH, '//*[normalize-space()="Pandoc Markdown"]'
).click()
path = os.path.join(self.download_dir, "title.markdown.zip")
self.wait_until_file_exists(path, self.wait_time)
assert os.path.isfile(path)
os.remove(path)

# Export as RTF
self.driver.find_element(
By.CSS_SELECTOR,
'.header-nav-item[title="Export of the document contents"]',
).click()
self.driver.find_element(
By.XPATH, '//*[normalize-space()="Richtext"]'
).click()
path = os.path.join(self.download_dir, "title.rtf")
self.wait_until_file_exists(path, self.wait_time)
assert os.path.isfile(path)
os.remove(path)

0 comments on commit 62cd945

Please sign in to comment.