diff --git a/.gitignore b/.gitignore index bacd1f0..192a733 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ .eggs env/* __pycache__ -site \ No newline at end of file +site +examples/*.html + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e1878bd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "c:\\Users\\dang\\Documents\\GitHub\\MarkdownMark\\env\\Scripts\\python.exe" +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db0fc0..6303bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.3.2 + + - Entry point script uses the generic template (feedback.jinja2) by default + # 0.3.1 - Software diff --git a/remarkable/scripts/runDMC.py b/remarkable/scripts/runDMC.py index 317c19a..1edec37 100644 --- a/remarkable/scripts/runDMC.py +++ b/remarkable/scripts/runDMC.py @@ -57,7 +57,8 @@ def main(): help="File to Convert") parser.add_argument("-t", "--template", - help="Template file to use for rendering") + default="feedback.jinja2", + help="Template file to use for rendering. Will default to generic marking template (feedback.jinja2)") parser.add_argument("-d", "--templatedir", help="Local template directory") diff --git a/remarkable/templates/feedback.jinja2 b/remarkable/templates/feedback.jinja2 index cad7e84..40e81a2 100644 --- a/remarkable/templates/feedback.jinja2 +++ b/remarkable/templates/feedback.jinja2 @@ -1,11 +1,12 @@ {% extends "base/bootstrap.jinja2" %} {% block content %} - +{# -------------------- Header Section ------------------------ #}
Some Input from a markdown file
""" + if not outFile: + outFile = os.path.join(self.tmpdir.name, "render.html") + fd = open(outFile, "r") out = fd.read() fd.close() diff --git a/test/test_markdown.py b/test/test_markdown.py index 79c32c5..1b9cecd 100644 --- a/test/test_markdown.py +++ b/test/test_markdown.py @@ -7,16 +7,13 @@ I just ran down https://www.markdownguide.org/basic-syntax/ import unittest import os +import tempfile import bs4 import remarkable.parser as parser import remarkable.renderer as renderer - - -OUTFILE = "/tmp/syntaxtest.html" - class markdownTest(unittest.TestCase): """ Test cases for markdown rendering. @@ -30,19 +27,19 @@ class markdownTest(unittest.TestCase): """ Keep the parser and input file consistent """ + tmpdir = tempfile.TemporaryDirectory() + cls.outfile = os.path.join(tmpdir.name, "syntaxtest.html") + print ("Create temproary file {0}".format(cls.outfile)) + cls.theParser = parser.MarkdownParser("test/inputs/markdownSyntax.md") cls.theParser.parseFile() cls.theRenderer = renderer.HTMLRenderer("syntax.jinja2", "test/templates") - cls.theRenderer.toFile(cls.theParser, OUTFILE) + cls.theRenderer.toFile(cls.theParser, cls.outfile) #And Beautiful soup version - with open(OUTFILE, "r") as fd: + with open(cls.outfile, "r") as fd: cls.soup = bs4.BeautifulSoup(fd, features="html.parser") - @classmethod - def tearDownClass(cls): - if os.path.exists(OUTFILE): - os.remove(OUTFILE) def cleanBS(self, theInput): """ diff --git a/test/test_render.py b/test/test_render.py index 4701672..db7fb32 100644 --- a/test/test_render.py +++ b/test/test_render.py @@ -1,4 +1,6 @@ import unittest +import os +import tempfile import jinja2 @@ -13,6 +15,12 @@ class renderTest(unittest.TestCase): However, if things start failing its something to eyeball """ + @classmethod + def setUpClass(cls): + """Setup the temp directory to hold any generated files""" + + cls.tmpdir = tempfile.TemporaryDirectory() + def setUp(self): """ Parse the file and get the rendered output. @@ -236,7 +244,8 @@ For example new lines. #And Renderer theRenderer = renderer.HTMLRenderer("testingMD.jinja2", "test/templates") - out = theRenderer.toFile(theParser, "/tmp/testout.html") + filename = os.path.join(self.tmpdir.name, "testout.html") + out = theRenderer.toFile(theParser, filename) expected = """And More Spacing to be dealt with
""" - fd = open("/tmp/testout.html", "r") + fd = open(filename, "r") out = fd.read() fd.close()