Repository: debrief/pepys-import

Issue:
Highlighted file should have fixed width font
This isn't a step to introduce lots of formatting, but we should Style the content of the extraction highlight file to have fixed width font.

Discussion:

Patch:
diff --git a/pepys_import/file/highlighter/support/export.py b/pepys_import/file/highlighter/support/export.py
index b62a2685..b873a504 100644
--- a/pepys_import/file/highlighter/support/export.py
+++ b/pepys_import/file/highlighter/support/export.py
@@ -16,6 +16,14 @@ def export_report(filename, chars, dict_colors, include_key=False):
 
     f_out = open(filename, "w")
 
+    html_header = """<html>
+    <head>
+    </head>
+    <body style="font-family: Courier">
+    """
+
+    f_out.write(html_header)
+
     last_hash = ""
 
     for char in chars:
@@ -92,4 +100,9 @@ def export_report(filename, chars, dict_colors, include_key=False):
             )
         f_out.write("</ul>")
 
+    html_footer = """</body>
+    </html>"""
+
+    f_out.write(html_footer)
+
     f_out.close()
diff --git a/pepys_import/file/highlighter/support/line.py b/pepys_import/file/highlighter/support/line.py
index b7e03991..2b1ef0fc 100644
--- a/pepys_import/file/highlighter/support/line.py
+++ b/pepys_import/file/highlighter/support/line.py
@@ -82,19 +82,23 @@ class Line:
 
         return self.tokens_array
 
-    def record(self, tool, message):
+    def record(self, tool: str, field: str, value: str, units: str = "n/a"):
         """
         Record a usage of the whole line, by adding a SingleUsage object to each of the
         relevant characters in the char array referenced by each SubToken child.
 
         Args:
-            tool (str): The name of the parser tool that has identified the field
-            message (str): A description of how the data has been interpreted, and
-            what will represent it in the database
+            tool(str):  name of the module handling the import
+            field(str): what the token is being interpreted as
+            value(str): what value the token provided
+            units(str): the units of the token
         """
         self.highlighted_file.fill_char_array_if_needed()
 
+        tool_field = tool + "/" + field
+        message = "Value:" + str(value) + " Units:" + str(units)
+
         for child in self.children:
             for i in range(int(child.start()), int(child.end())):
-                usage = SingleUsage(tool, message)
+                usage = SingleUsage(tool_field, message)
                 child.chars[i].usages.append(usage)


Test patch:
diff --git a/tests/highlighter_tests/test_Recording.py b/tests/highlighter_tests/test_Recording.py
index 0ddf95c4..feb54137 100644
--- a/tests/highlighter_tests/test_Recording.py
+++ b/tests/highlighter_tests/test_Recording.py
@@ -92,12 +92,12 @@ class UsageRecordingTests(unittest.TestCase):
         self.assertEqual("Value:VALUE Units:UNITS", first_usage.message)
 
         # make another recordd
-        firstLine.record(field, value)
+        firstLine.record(tool, field, value, units)
         self.assertEqual(2, len(first_entry.usages))
         second_usage = first_entry.usages[1]
         self.assertTrue(second_usage is not None, "should have a usage")
-        self.assertEqual("FIELD", second_usage.tool_field)
-        self.assertEqual("VALUE", second_usage.message)
+        self.assertEqual("TOOL/FIELD", second_usage.tool_field)
+        self.assertEqual("Value:VALUE Units:UNITS", second_usage.message)
 
     def test_multi_lines(self):
         dataFile = HighlightedFile(DATA_FILE)
diff --git a/tests/highlighter_tests/test_html.py b/tests/highlighter_tests/test_html.py
new file mode 100644
index 00000000..8623af3b
--- /dev/null
+++ b/tests/highlighter_tests/test_html.py
@@ -0,0 +1,35 @@
+import os
+import unittest
+from pepys_import.file.highlighter.highlighter import HighlightedFile
+
+path = os.path.abspath(__file__)
+dir_path = os.path.dirname(path)
+
+DATA_FILE = os.path.join(dir_path, "sample_files/file.txt")
+OUTPUT_FOLDER = os.path.join(dir_path, "sample_files/")
+
+
+class TestHTML(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        if os.path.exists(os.path.join(OUTPUT_FOLDER, "test_highlighted.html")):
+            os.remove(os.path.join(OUTPUT_FOLDER, "test_highlighted.html"))
+        pass
+
+    def test_html_is_monospaced(self):
+        dataFile = HighlightedFile(DATA_FILE)
+
+        lines = dataFile.lines()
+        lines[0].record("Test Name", "Test Field", "Test Value", "Test Units")
+
+        output_file = os.path.join(OUTPUT_FOLDER, "test_highlighted.html")
+
+        dataFile.export(output_file, True)
+
+        with open(output_file, "r") as f:
+            output_contents = f.read()
+
+        assert "<html>" in output_contents
+        assert '<body style="font-family: Courier">' in output_contents