diff --git a/index.js b/index.js index b37ef7e..64bb90b 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ var files = []; var unknown = []; var VERBOSE = false; -var FILEGREP = /CIDE.V/; +var FILEGREP = /CIDE/; var ONLYWEBSTER = true; @@ -64,18 +64,24 @@ function replaceEntities(string) { function replaceVarious(string) { + // Remove comments + string = string.replace(/<\!--.*?-->/g, ''); + // Nicer long dashes + string = string.replace(/--/g, '–'); + string = string.replace(/---/g, '–'); + + //Double bar string = string.replace(/\|\|/g, '‖'); string = string.replace(/\\'d8/g, '‖'); + + //Empty prounounciation tags string = string.replace(/\s*\(\?\)<\/pr>/g, ''); string = string.replace(/\s*\(�\)<\/pr>/g, ''); - // Move whitespace inside tags - // Twice + // Move whitespace inside tags, twice string = string.replace(/<\/(\w+?)>(\s+)/g, '$2'); string = string.replace(/<\/(\w+?)>(\s+)/g, '$2'); - //string = string.replace(/\s*/g, ''); - return string; } @@ -121,7 +127,6 @@ function greekToUTF8(input) { } - function processFiles() { dir.readFiles('srcFiles', { match: FILEGREP @@ -176,19 +181,6 @@ function prelim() { } -function jsonToXML() { - fs.readFile('output/dict.json', 'utf8', function (err, data) { - if (err) throw err; - dictionary = JSON.parse(data); - - var xml = buildXML(); - fs.writeFile('template/dict.xml', xml, 'utf8', function (err) { - if (err) throw err; - console.log('Wrote file'); - }); - }); - -} function parseFiles(cb) { var q = async.queue(function (task, callback) { @@ -235,7 +227,6 @@ function parseFile(file) { next.remove(); } - var ent = $(this).find('ent'); if (ent.length) { curEntryName = ent.first().text(); @@ -246,6 +237,7 @@ function parseFile(file) { ent.each(function () { index[curEntryName].push($(this).text()); + if ($(this).next().is('br')) $(this).next().remove(); }); ent.remove(); @@ -257,9 +249,12 @@ function parseFile(file) { if (children.last().is('br')) children.last().remove(); - var hw = $(this).find('hw, wf'); + var hw = $(this).find('hw, wf, pr'); hw.each(function () { var text = $(this).text(); + text = text.replace(/\*/g, '-'); + text = text.replace(/\"/g, '′'); + text = text.replace(/`/g, 'ˊ'); text = text.replace(/'/g, '’'); $(this).html(text); }); @@ -294,40 +289,28 @@ function wrapAll(elements, structure, $) { } function postProcessDictionary() { - var dashes = new RegExp('\\s+[-]{2,3}\\s+','g'); var i = 0; delete dictionary.NOTHING; for (var entry in dictionary) { - var text = dictionary[entry]; - text = text.replace(dashes, ' — '); + var text = dictionary[entry].trim(); + text = text.replace(/\s+[-]{2,3}\s+/, ' — '); + text = text.replace(/\'/, '’'); // Wrap loose sentencens var $ = cheerio.load(text, { xmlMode: true }); - $('hw').each(function() { - var intro = $(this).nextUntil('def, sn'); - wrapAll(intro, '', $); - - var block = $(this).nextUntil('hw'); - wrapAll(block, '', $); - }); - - $('def').each(function () { - var extra = $(this).nextUntil('hw, sn'); - wrapAll(extra, '', $); - }); - - $('q+rj').each(function () { - var quote = $(this).prev(); - var author = $(this).find('qau'); + $('q').each(function () { + var quote = $(this); + var next = quote.next(); + var author = next.find('qau'); if (author.length) { quote.append(author); + next.remove(); } - $(this).remove(); }); // Change tag types diff --git a/template/OtherResources/GenBasI.ttf b/template/OtherResources/GenBasI.ttf deleted file mode 100755 index 0dd6405..0000000 Binary files a/template/OtherResources/GenBasI.ttf and /dev/null differ diff --git a/template/OtherResources/GenBasR.ttf b/template/OtherResources/GenBasR.ttf deleted file mode 100755 index 4d263b8..0000000 Binary files a/template/OtherResources/GenBasR.ttf and /dev/null differ diff --git a/template/OtherResources/GentiumPlus-I-smcp.woff b/template/OtherResources/GentiumPlus-I-smcp.woff new file mode 100644 index 0000000..88ef517 Binary files /dev/null and b/template/OtherResources/GentiumPlus-I-smcp.woff differ diff --git a/template/OtherResources/GentiumPlus-I.ttf b/template/OtherResources/GentiumPlus-I.ttf new file mode 100755 index 0000000..df922fd Binary files /dev/null and b/template/OtherResources/GentiumPlus-I.ttf differ diff --git a/template/OtherResources/GentiumPlus-R-smcp.woff b/template/OtherResources/GentiumPlus-R-smcp.woff new file mode 100644 index 0000000..b015509 Binary files /dev/null and b/template/OtherResources/GentiumPlus-R-smcp.woff differ diff --git a/template/OtherResources/GentiumPlus-R.ttf b/template/OtherResources/GentiumPlus-R.ttf new file mode 100755 index 0000000..d80226c Binary files /dev/null and b/template/OtherResources/GentiumPlus-R.ttf differ diff --git a/template/styles.css b/template/styles.css index bfb5bd0..7b221a1 100644 --- a/template/styles.css +++ b/template/styles.css @@ -5,14 +5,14 @@ font-family: "Gentium"; font-style: normal; font-weight: normal; - src: url(GenBasR.ttf) + src: url(GentiumPlus-R.ttf) } @font-face { font-family: "Gentium"; font-style: italic; font-weight: normal; - src: url(GenBasI.ttf) + src: url(GentiumPlus-I.ttf) } @font-face { @@ -22,6 +22,20 @@ src: url(GenBasB.ttf) } +@font-face { + font-family: "GentiumSMCP"; + font-style: normal; + font-weight: normal; + src: url(GentiumPlus-R-smcp.woff) +} + +@font-face { + font-family: "GentiumSMCP"; + font-style: italic; + font-weight: normal; + src: url(GentiumPlus-I-smcp.woff) +} + body { line-height: 1.3; } @@ -63,7 +77,7 @@ div { } .qau:before, .au:before { - content: "–"; + content: "– "; } *+.hw:before { @@ -82,18 +96,15 @@ div { white-space:pre; } -.q+.sn:before, .cs .sd:before { +.q + .sn:before, .cs .sd:before, .q + .sd:before { content:""; white-space:initial; } -.au { +.au, .qau { font-size: 90%; } -.qau { - font-size: 79%; -} .xex, .it, .title, .stype, .part, .parts, .membof, .member, .members, .corr, .qperson, .prod, .prodmac, .stage, .stageof, @@ -105,14 +116,6 @@ div { font-style: italic; } -.col:before, .sn:before { - content:"\A"; white-space:pre; -} - -.block+.hw:before { - content:"\A\A"; white-space:pre; -} - .q { font-size: 86%; line-height: 1.3; @@ -121,11 +124,24 @@ div { } .u, .plw, .er { - font-variant: small-caps; underline: none; text-decoration: none; } +.u, .plw, .er { + font-family: 'GentiumSMCP'; +} + +@supports(font-feature-settings: 'smcp') { + .u, .plw, .er { + font-family: inherit + font-variant: normal; + font-feature-settings: 'smcp'; + } +} + + + .sn { font-weight:bold; font-size: 105%