Add nya filter
This commit is contained in:
parent
17bc0d4844
commit
f844a47f1d
4 changed files with 27 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ module.exports = ~>
|
|||
data =
|
||||
cache: true
|
||||
debug: false
|
||||
nya: true
|
||||
home: home-data
|
||||
|
||||
return data
|
||||
|
|
|
|||
|
|
@ -14,3 +14,5 @@ module.exports = (me) ->
|
|||
if data?
|
||||
Object.assign me, data
|
||||
me.trigger \updated
|
||||
|
||||
me: me
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
const riot = require('riot');
|
||||
|
||||
module.exports = function(tokens, canBreak, escape) {
|
||||
if (canBreak == null) {
|
||||
canBreak = true;
|
||||
|
|
@ -5,7 +7,10 @@ module.exports = function(tokens, canBreak, escape) {
|
|||
if (escape == null) {
|
||||
escape = true;
|
||||
}
|
||||
return tokens.map(function(token) {
|
||||
|
||||
const me = riot.mixin('i').me;
|
||||
|
||||
let text = tokens.map(function(token) {
|
||||
switch (token.type) {
|
||||
case 'text':
|
||||
if (escape) {
|
||||
|
|
@ -27,4 +32,10 @@ module.exports = function(tokens, canBreak, escape) {
|
|||
return '<a>' + token.content + '</a>';
|
||||
}
|
||||
}).join('');
|
||||
|
||||
if (me && me.data && me.data.nya) {
|
||||
text = text.replace(/な/g, 'にゃ');
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue