diff --git a/amanuensis/parser/__init__.py b/amanuensis/parser/__init__.py
index 7c39cf5..a7424ae 100644
--- a/amanuensis/parser/__init__.py
+++ b/amanuensis/parser/__init__.py
@@ -2,6 +2,6 @@
Module encapsulating all markdown parsing functionality
"""
-from amanuensis.parser.analyze import WordCounter
+from amanuensis.parser.analyze import FeatureCounter
from amanuensis.parser.text import parse_raw_markdown
from amanuensis.parser.render import PreviewHtmlRenderer
\ No newline at end of file
diff --git a/amanuensis/parser/analyze.py b/amanuensis/parser/analyze.py
index f503463..3917c3b 100644
--- a/amanuensis/parser/analyze.py
+++ b/amanuensis/parser/analyze.py
@@ -5,20 +5,41 @@ for verification against constraints.
import re
-class WordCounter():
+class FeatureCounter():
+ def __init__(self):
+ self.word_count = 0
+ self.citation_count = 0
+ self.has_signature = False
+
def TextSpan(self, span):
- return len(re.split('\s+', span.innertext.strip()))
+ self.word_count += len(re.split('\s+', span.innertext.strip()))
+ return self
+
def LineBreak(self, span):
- return 0
+ return self
+
def ParsedArticle(self, span):
- return sum(span.recurse(self))
+ span.recurse(self)
+ return self
+
def BodyParagraph(self, span):
- return sum(span.recurse(self))
+ span.recurse(self)
+ return self
+
def SignatureParagraph(self, span):
- return sum(span.recurse(self))
+ self.has_signature = True
+ span.recurse(self)
+ return self
+
def BoldSpan(self, span):
- return sum(span.recurse(self))
+ span.recurse(self)
+ return self
+
def ItalicSpan(self, span):
- return sum(span.recurse(self))
+ span.recurse(self)
+ return self
+
def CitationSpan(self, span):
- return sum(span.recurse(self))
+ self.citation_count += 1
+ span.recurse(self)
+ return self
diff --git a/amanuensis/parser/render.py b/amanuensis/parser/render.py
index 3beb4b5..c6c00a4 100644
--- a/amanuensis/parser/render.py
+++ b/amanuensis/parser/render.py
@@ -7,19 +7,26 @@ readable formats.
class PreviewHtmlRenderer():
def TextSpan(self, span):
return span.innertext
+
def LineBreak(self, span):
return '
'
+
def ParsedArticle(self, span):
return '\n'.join(span.recurse(self))
+
def BodyParagraph(self, span):
return f'
{"".join(span.recurse(self))}
' + def SignatureParagraph(self, span): return ('' f'{"".join(span.recurse(self))}' '
') + def BoldSpan(self, span): return f'{"".join(span.recurse(self))}' + def ItalicSpan(self, span): return f'{"".join(span.recurse(self))}' + def CitationSpan(self, span): return f'{"".join(span.recurse(self))}' diff --git a/amanuensis/resources/editor.js b/amanuensis/resources/editor.js index d1d9978..a8c77fa 100644 --- a/amanuensis/resources/editor.js +++ b/amanuensis/resources/editor.js @@ -46,7 +46,9 @@ function update(article) { req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { // params.article = article; - document.getElementById("preview").innerHTML = req.response.rendered; + var title = document.getElementById("editor-title").value; + var previewHtml = "