aboutsummaryrefslogtreecommitdiff
path: root/lib/heuristics-processor.js
blob: 1c49f9dffe1eb8687883ce07f0c4d9d5363cd0d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
exports.HeuristicsProcessor = HeuristicsProcessor;

var q = require("q");

function HeuristicsProcessor() {
    function processHeuristics(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]);
                    break;
            }
        }
        return document;
    }

    function processParagraph(element) {
        if (element.alignment == 'center' && !element.styleName) {
            element.styleName = "CenteredHeading";
        }
        return element;
    }

    return {
        processHeuristics: processHeuristics
    }
}