-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ I've got another confession to make
- Loading branch information
0 parents
commit a868a00
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# GitHub emojis for Marked 2 | ||
|
||
[Marked 2](http://marked2app.com/) is a great markdown previewer and it works | ||
really well with GitHub styles. | ||
It does not display GitHub emojis though. | ||
This repo contains a preprocessor to add support for emojis, so you can write | ||
`:octocat:` in your code and see an emoji in previewer. | ||
|
||
## Install | ||
|
||
1. Download zip file. It contains emojis from GitHub and a preprocessor file. | ||
1. In Marked 2 application open "Preferences" -> "Advanced" -> "Preprocessor". | ||
1. Check "Enable Custom Preprocessor". | ||
1. In "Path" field type in path to `preprocessor.sh` file inside downloaded | ||
folder from step 1. | ||
1. Done. | ||
|
||
## Build | ||
|
||
You can build and download all files yourself. | ||
|
||
1. Clone the repo. | ||
1. Run `build.sh` file. It will download emojis from GitHub and build | ||
a preprocessor file. Please note that downloading may take some time. | ||
1. In Marked 2 application open "Preferences" -> "Advanced" -> "Preprocessor". | ||
1. Check "Enable Custom Preprocessor". | ||
1. In "Path" field type in path to `preprocessor.sh` file inside the repo. | ||
1. Done. | ||
|
||
## Issues | ||
|
||
1. Preprocessor is not smart enough so it will show emojis inside code blocks | ||
too. | ||
1. Preprocessor uses `sed` command for replacement so it must be present on your | ||
computer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
curl https://api.github.com/emojis > emojis.json && ./scripts-maker.js && bash downloader.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
var fs = require('fs'); | ||
var emojis = require('./emojis.json'); | ||
|
||
var PREPROCESSOR_FILE = 'preprocessor.sh'; | ||
var DOWNLOADER_FILE = 'downloader.sh'; | ||
|
||
var preprocessorData = ['#!/bin/bash', 'sed \'']; | ||
var downloaderData = ['#!/bin/bash', 'rm -rf emojis', 'mkdir emojis']; | ||
|
||
for (var emoji in emojis) { | ||
var url = emojis[emoji]; | ||
var filename = getFilenameFromUrl(url); | ||
|
||
addDataToPreprocessor(emoji, filename); | ||
addDataToDownloader(url, filename); | ||
} | ||
|
||
preprocessorData.push(' \''); | ||
|
||
fs.writeFileSync(PREPROCESSOR_FILE, preprocessorData.join('\n')); | ||
fs.writeFileSync(DOWNLOADER_FILE, downloaderData.join('\n')); | ||
|
||
function escape(str) { | ||
return str.replace(/\//g, '\\/'); | ||
} | ||
|
||
function getFilenameFromUrl(url) { | ||
return url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('?')); | ||
} | ||
|
||
function addDataToPreprocessor(emoji, filename) { | ||
var src = escape(__dirname + '/emojis/' + filename); | ||
var string = ' s/:' + emoji + | ||
':/<img style="height:20px;vertical-align:middle;" src="' + src + '">/;'; | ||
preprocessorData.push(string); | ||
} | ||
|
||
function addDataToDownloader(url, filename) { | ||
var string = 'curl ' + url + ' > emojis/' + filename; | ||
downloaderData.push(string); | ||
} |