Skip to content

Commit 756ba4c

Browse files
committed
change comment schema to allow #
See discussion in #1 Fixes #1
1 parent 6782f61 commit 756ba4c

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

scripts/build.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ const buildFolder = path.join(scriptDir, '..', "build");
1111
const buildRawFolder = path.join(buildFolder, "raw");
1212
const atlas = {}
1313
const files = fs.readdirSync(mapsFolder)
14+
const isRule = (line) => {
15+
return line.length < 10 && line.indexOf('=') > -1
16+
}
17+
const isComment = (line) => !isRule(line)
1418
files.forEach((file) => {
1519
const filePath = path.join(mapsFolder, file);
1620

1721
const data = fs.readFileSync(filePath, 'utf8')
1822
const fontName = path.parse(file).name;
1923
const fontMap = {};
2024
data.split('\n').forEach(l => {
21-
if (l.startsWith('#')) return;
25+
l = l.trim();
26+
if (isComment(l)) return;
2227
const [lhs, rhs] = l.split('=').map(w => w.trim());
2328
if (lhs) fontMap[lhs] = rhs;
2429
})

scripts/find-longest.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
const filename = process.argv[2];
3+
if (!filename) {
4+
console.error("Please specify filename");
5+
process.exit(1);
6+
}
7+
const text = fs.readFileSync(filename, 'utf-8');
8+
const known = {}
9+
let longest = ""
10+
let longestLength = 0
11+
text
12+
.split('\n')
13+
.forEach(l => {
14+
if (l.startsWith('#')) return;
15+
if (l.length > longestLength) {
16+
longest = l;
17+
longestLength = l.length
18+
}
19+
})
20+
21+
console.log(longest)
22+
console.log(longestLength)

0 commit comments

Comments
 (0)