Skip to content

Commit d99fde3

Browse files
committed
Deal with fact that github auto-escapes link titles.
If you type [This is my+title It's #super# *great*](some-link) Github will store [This is my\+title It's \#super\# \*great\*](some-link) Or something like that. It's not clear if it's defined anywhere what gets escaped.
1 parent 47d7f73 commit d99fde3

File tree

3 files changed

+11101
-5
lines changed

3 files changed

+11101
-5
lines changed

build/update-songs.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ const path = require('path');
55
const lzma = require('lzma');
66

77
async function getComments() {
8-
if (process.argv[2]) {
9-
const body = fs.readFileSync(process.argv[2], {encoding: 'utf-8'});
8+
const filename = process.argv[2];
9+
if (filename) {
10+
const content = fs.readFileSync(process.argv[2], {encoding: 'utf-8'});
11+
if (filename.endsWith('.json')) {
12+
return JSON.parse(content);
13+
}
1014
return [
1115
{
12-
body,
16+
body: content,
1317
reactions: {},
1418
user: {
1519
id: 123,
@@ -36,7 +40,7 @@ async function getComments() {
3640
repo: 'html5bytebeat',
3741
issue_number: '17',
3842
headers: {
39-
Accept: 'application/vnd.github.raw+json',
43+
accept: 'application/vnd.github.v3.raw+json',
4044
},
4145
});
4246
return comments;
@@ -89,6 +93,8 @@ async function main() {
8993
songs.push(...results.map(([, title, link]) => {
9094
const {code} = readURL(link.substring(link.indexOf('#') + 1));
9195
const size = minimize(code).length;
96+
// fix title -- this seems hacked to me
97+
title = title.replaceAll(/\\(.)/g, '$1');
9298
return {title, size, link, reactions, groupSize: results.length, user: {login, id}};
9399
}));
94100
}

editor/songs.json

Lines changed: 11090 additions & 1 deletion
Large diffs are not rendered by default.

test/comments-from-github-pass-to-update-songs.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)