From db8258dd7a957afd00f17bfbfb5b76d380110c0e Mon Sep 17 00:00:00 2001 From: "Chen, Chien-ting" Date: Mon, 30 Jul 2018 00:20:34 +0800 Subject: [PATCH] Create furi.js --- furi.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 furi.js diff --git a/furi.js b/furi.js new file mode 100644 index 0000000..e252657 --- /dev/null +++ b/furi.js @@ -0,0 +1,22 @@ +/* +furi.js (former furigana.js): A filter for Hexo to generate 2-language comparison like furigana. Place this file in /scripts/furigana.js. +======================================================================== +Author: Yoxem ,kuanyui(azazabc123[at]g~~~m~~~a~~~i~~~l[dot]com) +Date: 20180730 +License: WTFPL 1.0 +======================================================================== +The string in article: + {fr|平安|peace} +Will be converted to: 2 lines. +*/ + +hexo.extend.filter.register('post', function(data, callback) { + var reRb = new RegExp('\\{fr\\|(.+?)\\|(.+?)\\}', 'g'); + data.content = data.content.replace(reRb, '
$1
$2
'); + +// fre: added to the end punctuation of the line. eg. {fr|Eh|e}{frb|?} + var reRb = new RegExp('\\{fre\\|(.+?)\\}', 'g'); + data.content = data.content.replace(reRb, '
$1
'); + //callback(null, data); + return data; +});