|
|
@ -1,4 +1,4 @@ |
|
|
|
// Simple typographyc replacements
|
|
|
|
// Simple typographic replacements
|
|
|
|
//
|
|
|
|
// '' → ‘’
|
|
|
|
// "" → “”. Set '«»' for Russian, '„“' for German, empty to disable
|
|
|
@ -6,6 +6,10 @@ |
|
|
|
// (tm) (TM) → ™
|
|
|
|
// (r) (R) → ®
|
|
|
|
// +- → ±
|
|
|
|
// <3 → ♥
|
|
|
|
// <-> → ↔
|
|
|
|
// <- → ←
|
|
|
|
// -> → →
|
|
|
|
// (p) (P) -> §
|
|
|
|
// ... → … (also ?.... → ?.., !.... → !..)
|
|
|
|
// ???????? → ???, !!!!! → !!!, `,,` → `,`
|
|
|
@ -17,7 +21,7 @@ |
|
|
|
// - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
|
|
|
|
// - miltiplication 2 x 4 -> 2 × 4
|
|
|
|
|
|
|
|
var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/; |
|
|
|
var RARE_RE = /\+-|<3|->|<-|\.\.|\?\?\?\?|!!!!|,,|--/; |
|
|
|
|
|
|
|
var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig; |
|
|
|
var SCOPED_ABBR = { |
|
|
@ -56,6 +60,10 @@ module.exports = function replace(state) { |
|
|
|
|
|
|
|
if (RARE_RE.test(text)) { |
|
|
|
text = text.replace(/\+-/g, '±') |
|
|
|
.replace(/<3/g, '♥') |
|
|
|
.replace(/<->/g, '↔') |
|
|
|
.replace(/<-/g, '←') |
|
|
|
.replace(/->/g, '→') |
|
|
|
// .., ..., ....... -> …
|
|
|
|
// but ?..... & !..... -> ?.. & !..
|
|
|
|
.replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..') |
|
|
|