mirror of
https://github.com/ikatyang/emoji-cheat-sheet.git
synced 2024-11-22 10:23:51 +01:00
Update markdown format
add back to top links add some descriptions
This commit is contained in:
parent
f667d30e60
commit
632aae66e0
@ -36,6 +36,6 @@ request.get(url, (error, response, body) => {
|
||||
} else {
|
||||
fs.mkdirSync(outDir);
|
||||
}
|
||||
fs.writeFileSync(outFile, markdown.create(title, emojiTable, columnDivisions));
|
||||
fs.writeFileSync(outFile, markdown.create(url, title, emojiTable, columnDivisions));
|
||||
}
|
||||
});
|
||||
|
@ -2,17 +2,24 @@ const format = str => str.trim().replace(/^ +/mg, '');
|
||||
|
||||
module.exports = class Markdown {
|
||||
|
||||
static create(title, emojiTable, columnDivisions) {
|
||||
static create(url, title, emojiTable, columnDivisions) {
|
||||
const emojiCatalogs = Object.keys(emojiTable);
|
||||
return format(`
|
||||
|
||||
# ${title}
|
||||
|
||||
This cheat sheet is auto-generated from <${url}> using [emoji-cheat-sheet-generator](https://github.com/ikatyang/emoji-cheat-sheet/tree/master).
|
||||
|
||||
## Table of Contents
|
||||
|
||||
${emojiCatalogs.map(catalog => `- [${catalog}](#${catalog.toLowerCase()})`).join('\n')}
|
||||
|
||||
${
|
||||
Object.keys(emojiTable).map(catalog => {
|
||||
emojiCatalogs.map(catalog => {
|
||||
const emojis = emojiTable[catalog];
|
||||
return format(`
|
||||
|
||||
#### ${catalog}
|
||||
## ${catalog}
|
||||
|
||||
${this.createTable(emojis, columnDivisions)}
|
||||
|
||||
@ -26,8 +33,8 @@ module.exports = class Markdown {
|
||||
static createTableHead(columnDivisions) {
|
||||
return format(`
|
||||
|
||||
|${(' icon | emoji |').repeat(columnDivisions)}
|
||||
|${(' ---- | ----- |').repeat(columnDivisions)}
|
||||
| |${(' icon | emoji |').repeat(columnDivisions)}
|
||||
| - |${(' ---- | ----- |').repeat(columnDivisions)}
|
||||
|
||||
`);
|
||||
}
|
||||
@ -40,7 +47,7 @@ module.exports = class Markdown {
|
||||
rowEmojis.push('');
|
||||
table += format(`
|
||||
|
||||
|${rowEmojis.map((emoji) => ` :${emoji}: | \`:${emoji}:\` `).join(' | ')}|
|
||||
| [↑](#table-of-contents) |${rowEmojis.map((emoji) => ` :${emoji}: | \`:${emoji}:\` `).join(' | ')}|
|
||||
|
||||
`) + '\n';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user