From af8544bb75a971dcf9a13500eb597bcab7619ec7 Mon Sep 17 00:00:00 2001 From: "Chen, Chien-ting" Date: Mon, 30 Jul 2018 00:21:10 +0800 Subject: [PATCH] Create ruby.js --- ruby.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 ruby.js diff --git a/ruby.js b/ruby.js new file mode 100644 index 0000000..aefd258 --- /dev/null +++ b/ruby.js @@ -0,0 +1,19 @@ +/* +ruby.js: A filter for Hexo to generate ruby chracters(ルビ). Place this file in /scripts/ruby.js. +======================================================================== +Author: kuanyui(azazabc123[at]g~~~m~~~a~~~i~~~l[dot]com), Yoxem +Date: 20180730 +License: WTFPL 1.0 +======================================================================== +The string in article: + {rb|機巧少女|machine doll} +Will be converted to: + 機巧少女[machine doll] +*/ + +hexo.extend.filter.register('post', function(data, callback) { + var reRb = new RegExp('\\{rb\\|(.+?)\\|(.+?)\\}', 'g'); + data.content = data.content.replace(reRb, '$1[$2]'); + // callback(null, data); + return data; +});