Skip to content
Permalink
Browse files
Merge with master
  • Loading branch information
aa9863 committed Jul 10, 2020
2 parents d50d07a + b8b4b81 commit db01137b9f72b5195f127115afdb6a328970e8eb
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 41 deletions.
@@ -3,4 +3,6 @@
.eggs
env/*
__pycache__
site
site
examples/*.html

@@ -0,0 +1,3 @@
{
"python.pythonPath": "c:\\Users\\dang\\Documents\\GitHub\\MarkdownMark\\env\\Scripts\\python.exe"
}
@@ -1,3 +1,7 @@
# 0.3.2

- Entry point script uses the generic template (feedback.jinja2) by default

# 0.3.1

- Software
@@ -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")
@@ -1,11 +1,12 @@
{% extends "base/bootstrap.jinja2" %}
{% block content %}


{# -------------------- Header Section ------------------------ #}
<div class="container-lg">
{% if header %}
<div class="row">
<div class="col-12">
<div class="col-8">
<h6>Module:</h6>
<h1>
{% if header.mod_code %}
{{ header.mod_code }} :
@@ -15,17 +16,23 @@
</div>
</div>

{% if header.cw %}
<div class="row">
<div class="col-12">
<h6>Cousework Title:</h6>
<h2> {{ header.cw }} </h2>
</div>
</div>
{% endif %}

{% if header.sid or header.student %}
<div class="row">
<div class="col-12">
<h6>Student:</h6>
<h2>{{ header.sid }} {{ header.student }}</h2>
</div>
</div>
{% endif %}

{% else %}
<div class="row">
@@ -38,18 +45,23 @@
{% endif %}

<!-- And the Content itself -->
{% for item in order %}
<div class="row">
<div class="col-10">
<h1>{{content[item].header}}</h1>
{{ content[item] }}
</div>
<div class="col-2 text-right">
<h1>{{ content[item].getMarks() }}<h1>
</div>
</div class="row">
{% endfor %}

{# -------------------- Content Section ------------------------ #}
<div class="row">
<div class="col-12">
{% for item in order %}
<div class="card">
<h1 class="card-header">
{{ content[item].header}}
<span class="float-right">{{ content[item].getMarks() }}</span>
</h1>
<div class="card-body">
{{ content[item] }}
</div>
</div>
{% endfor %}
</div>
</div>

<!-- Total Marks (If they Exist) -->
{% if calcs.marksAwarded %}
<div class="row">
@@ -1,5 +1,3 @@
import os

from setuptools import setup, find_packages

requires = [
@@ -20,22 +18,20 @@ setup(
name="remarkable",
author="Dan Goldsmith",
author_email="djgoldsmith@googlemail.com",
version="0.3.1",
version="0.3.2",
#Dependencies
install_requires=requires,
tests_require=testRequires,
#Load the Library
packages=find_packages(),
package_data = {"remarkable": ["templates/"]},
package_data={"remarkable": ["templates"]},

#And scripts
entry_points = {
entry_points={
"console_scripts":[
"DMC = remarkable.scripts.runDMC:main",
"runDMC = remarkable.scripts.runDMC:main",
"remarkable = remarkable.scripts.runDMC:main",
]
}
)


@@ -4,6 +4,8 @@ Testing for the Main Methods and Script Functions

import unittest
import os
import tempfile

import jinja2

import remarkable.controller as controller
@@ -18,24 +20,29 @@ class ControllerTest(unittest.TestCase):
```convertFile(inputFile, templateFile = None, templateDir=None, outputFile = None):```
"""

@classmethod
def setUpClass(cls):
"""Setup the temp directory to hold any generated files"""

cls.tmpdir = tempfile.TemporaryDirectory()

def tearDown(self):
"""
Called before all tests, make sure the tmp directory is clean
"""
if os.path.exists("/tmp/render.html"):
os.remove("/tmp/render.html")

#And if we dont sepcify a file
if os.path.exists("inputController.html"):
os.remove("inputController.html")

def testConvertAll(self):
""" Convert with all parameters supplied """

outFile = os.path.join(self.tmpdir.name, "render.html")

controller.convertFile("test/inputs/inputController.md",
"controller.jinja2",
"test/templates",
outputFile="/tmp/render.html")
outputFile=outFile)
self._checkOutput()


@@ -47,10 +54,12 @@ class ControllerTest(unittest.TestCase):
we look in the file header for a ```template:``` and use that
"""

outFile = os.path.join(self.tmpdir.name, "render.html")

controller.convertFile("test/inputs/inputController.md",
templateFile=None,
templateDir="test/templates",
outputFile="/tmp/render.html")
outputFile=outFile)
self._checkOutput()

def testNoOutput(self):
@@ -102,7 +111,7 @@ class ControllerTest(unittest.TestCase):
templateFile="missing.jinja")


def _checkOutput(self, outFile="/tmp/render.html"):
def _checkOutput(self, outFile=None):
"""
Helper function to check the output
@@ -114,6 +123,9 @@ class ControllerTest(unittest.TestCase):
<p>Some Input from a markdown file</p>"""

if not outFile:
outFile = os.path.join(self.tmpdir.name, "render.html")

fd = open(outFile, "r")
out = fd.read()
fd.close()
@@ -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):
"""
@@ -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.</p>

#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 = """<h2>Introduction</h2>
<span>10</span>
@@ -265,7 +274,7 @@ For example new lines.</p>
<p>And More Spacing to be dealt with</p>"""

fd = open("/tmp/testout.html", "r")
fd = open(filename, "r")
out = fd.read()
fd.close()

0 comments on commit db01137

Please sign in to comment.