manuskript/manuskript/converters/markdownConverter.py
Jan Wester ff2cbca028 Converted most print statements to use logging
Some snippets have yet to be converted due to the more complex nature
of those snippets, and to keep things neat a separate commit makes more
sense for those.
2021-04-08 18:44:28 +02:00

42 lines
855 B
Python

#!/usr/bin/env python
# --!-- coding: utf8 --!--
import os
import shutil
import subprocess
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import qApp, QMessageBox
from PyQt5.QtGui import QCursor
from manuskript.converters import abstractConverter
from manuskript.functions import mainWindow
import logging
LOGGER = logging.getLogger(__name__)
try:
import markdown as MD
except ImportError:
MD = None
class markdownConverter(abstractConverter):
"""
Converter using python module markdown.
"""
name = "python module markdown"
@classmethod
def isValid(self):
return MD != None
@classmethod
def convert(self, markdown):
if not self.isValid:
LOGGER.error("markdownConverter is called but not valid.")
return ""
html = MD.markdown(markdown)
return html