💄 Reformat with prettier

This commit is contained in:
kiliman
2020-12-18 09:33:55 -05:00
parent 8a32259fdc
commit 0d7089f840
+25 -26
View File
@@ -1,7 +1,7 @@
const fs = require('fs'); const fs = require('fs')
const rules = [ const rules = [
, '',
` `
lookup 1 { lookup 1 {
sub 1 by glyph; sub 1 by glyph;
@@ -30,37 +30,36 @@ lookup 1_2_3_4 {
sub 1.spacer 2' 3 4 by 2.spacer; sub 1.spacer 2' 3 4 by 2.spacer;
sub 1' 2 3 4 by 1.spacer; sub 1' 2 3 4 by 1.spacer;
} 1_2_3_4;`, } 1_2_3_4;`,
]; ]
const gencalt = (ligatures) => { const gencalt = ligatures => {
let calt = 'feature calt {\n'; let calt = 'feature calt {\n'
const ligs = {}; const ligs = {}
console.log(ligatures);
ligatures ligatures
.filter((l) => !!l.name.match(/\.liga$/) || l.name !== l.glyph) .filter(l => !!l.name.match(/\.liga$/) || l.name !== l.glyph)
.map((l) => l.glyph) .map(l => l.glyph)
.sort((a, b) => { .sort((a, b) => {
const length = b.split('_').length - a.split('_').length; const length = b.split('_').length - a.split('_').length
if (length !== 0) return length; if (length !== 0) return length
return a < b ? -1 : 1; return a < b ? -1 : 1
}) })
.forEach((g) => { .forEach(g => {
g.split('.') g.split('.')
.slice(0, 1) .slice(0, 1)
.forEach((l) => { .forEach(l => {
if (ligs[l]) return; if (ligs[l]) return
ligs[l] = true; ligs[l] = true
const c = l.split('_'); const c = l.split('_')
let rule = rules[c.length]; let rule = rules[c.length]
rule = rule rule = rule
.replace(/\d/g, (m) => c[parseInt(m) - 1]) .replace(/\d/g, m => c[parseInt(m) - 1])
.replace(/glyph/g, g); .replace(/glyph/g, g)
calt += rule + '\n'; calt += rule + '\n'
}); })
}); })
return calt + '\n} calt;\n'; return calt + '\n} calt;\n'
}; }
exports.gencalt = gencalt; exports.gencalt = gencalt