From b688f825e40c4bd20d645a9f145e4e445a4f66f0 Mon Sep 17 00:00:00 2001 From: Craig Leinoff Date: Tue, 7 Jan 2014 11:51:29 -0500 Subject: Renaming heuristics processing code to style applicator code. --- lib/style-applicator.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/style-applicator.js') diff --git a/lib/style-applicator.js b/lib/style-applicator.js index 0e3c97d..d6d909d 100644 --- a/lib/style-applicator.js +++ b/lib/style-applicator.js @@ -1,26 +1,30 @@ -exports.HeuristicsProcessor = HeuristicsProcessor; +exports.StyleApplicator = StyleApplicator; -function HeuristicsProcessor() { - function processHeuristics(document) { +function StyleApplicator(options) { + styleApplicatorOptions = options.styleApplicator || {}; + + function processDocumentStyles(document) { for (var i = 0; i < document.value.children.length; i++) { var element = document.value.children[i]; switch (element.type) { case 'paragraph': - document.value.children[i] = processParagraph(document.value.children[i]); + document.value.children[i] = processParagraphStyles(document.value.children[i]); break; } } return document; } - function processParagraph(element) { - if (element.alignment == 'center' && !element.styleName) { - element.styleName = "CenteredHeading"; + function processParagraphStyles(element) { + if (!element.styleName) { + if (styleApplicatorOptions.alignment && element.alignment) { + element.styleName = element.alignment+"Aligned"; + } } return element; } return { - processHeuristics: processHeuristics + processDocumentStyles: processDocumentStyles } } \ No newline at end of file -- cgit v1.2.3