diff options
| author | Craig Leinoff <leinoff@un.org> | 2014-01-07 11:51:29 -0500 |
|---|---|---|
| committer | Craig Leinoff <leinoff@un.org> | 2014-01-07 11:51:29 -0500 |
| commit | b688f825e40c4bd20d645a9f145e4e445a4f66f0 (patch) | |
| tree | 3b2aaab0ebb576fed0985bd85e95474bd43e89c8 /lib/style-applicator.js | |
| parent | b3cc8c0c5ce2aa2e556e995d587da5a00c6a3185 (diff) | |
Renaming heuristics processing code to style applicator code.
Diffstat (limited to 'lib/style-applicator.js')
| -rw-r--r-- | lib/style-applicator.js | 20 |
1 files changed, 12 insertions, 8 deletions
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 |
