Skip to content

Commit

Permalink
Great, small caps support
Browse files Browse the repository at this point in the history
  • Loading branch information
ponychicken committed Sep 2, 2014
1 parent 7976d03 commit e8e69bc
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 58 deletions.
65 changes: 24 additions & 41 deletions index.js
Expand Up @@ -14,7 +14,7 @@ var files = [];
var unknown = [];

var VERBOSE = false;
var FILEGREP = /CIDE.V/;
var FILEGREP = /CIDE/;
var ONLYWEBSTER = true;


Expand Down Expand Up @@ -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>\(\?\)<\/pr>/g, '');
string = string.replace(/\s*<pr>\(�\)<\/pr>/g, '');

// Move whitespace inside tags
// Twice
// Move whitespace inside tags, twice
string = string.replace(/<\/(\w+?)>(\s+)/g, '$2</$1>');
string = string.replace(/<\/(\w+?)>(\s+)/g, '$2</$1>');
//string = string.replace(/<br\/>\s*<hw>/g, '<hw>');


return string;
}
Expand Down Expand Up @@ -121,7 +127,6 @@ function greekToUTF8(input) {
}



function processFiles() {
dir.readFiles('srcFiles', {
match: FILEGREP
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -235,7 +227,6 @@ function parseFile(file) {
next.remove();
}


var ent = $(this).find('ent');
if (ent.length) {
curEntryName = ent.first().text();
Expand All @@ -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();
Expand All @@ -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, '&#x002d;');
text = text.replace(/\"/g, '&#8242;');
text = text.replace(/`/g, '&#x02CA;');
text = text.replace(/'/g, '’');
$(this).html(text);
});
Expand Down Expand Up @@ -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, '<intro>', $);

var block = $(this).nextUntil('hw');
wrapAll(block, '<block>', $);
});

$('def').each(function () {
var extra = $(this).nextUntil('hw, sn');
wrapAll(extra, '<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
Expand Down
Binary file removed template/OtherResources/GenBasI.ttf
Binary file not shown.
Binary file removed template/OtherResources/GenBasR.ttf
Binary file not shown.
Binary file added template/OtherResources/GentiumPlus-I-smcp.woff
Binary file not shown.
Binary file added template/OtherResources/GentiumPlus-I.ttf
Binary file not shown.
Binary file added template/OtherResources/GentiumPlus-R-smcp.woff
Binary file not shown.
Binary file added template/OtherResources/GentiumPlus-R.ttf
Binary file not shown.
50 changes: 33 additions & 17 deletions template/styles.css
Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down Expand Up @@ -63,7 +77,7 @@ div {
}

.qau:before, .au:before {
content: "–";
content: "– ";
}

*+.hw:before {
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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%
Expand Down

0 comments on commit e8e69bc

Please sign in to comment.