diff --git a/footnote.js b/footnote.js new file mode 100644 index 0000000..6f5d8cd --- /dev/null +++ b/footnote.js @@ -0,0 +1,49 @@ +/* +footnote.js: A filter for Hexo to generate footnotes. Place this file in /scripts/footnote.js. +======================================================================== +Author: kuanyui(azazabc123[at]g~~~m~~~a~~~i~~~l[dot]com), Yoxem (yoxem.tem98[ A T ]nctu.edu.tw) +Date: 20180730 +License: WTFPL 1.0 +======================================================================== +The following string in article + {fn|I'm the a lot lot of content.} +Will be converted into + 1 +And the following block will be added in the bottom of the article. +
+

Footnote

+
+
1

I'm the a lot lot of content.

+
2

I'm the second content2

+ ... +
+
+Adding following CSS into your site is recommended: +.footpara { + display: inline; + margin-left: 5px; +} +*/ + +var lang = {"en_US": "Footnotes", "zh_TW": "腳註", "ja_JP": "脚注", "zh_CN": "脚注", "nan": "注跤 [tsù-kha]"}; + +if (lang[hexo.config.language]) { + var fnName = lang[hexo.config.language]; +} else { + var fnName = "註腳"; +} + +hexo.extend.filter.register('pre', function(data, callback) { + var num = 0; + var footContent = ""; + var RE = new RegExp('\\{fn\\|(.+?)\\}', 'g'); + data.content = data.content.replace(RE, function(x, y) { + num += 1; + footContent += '
' + num + ' ' + y + '
'; + return '' + num + ''; + }); + if (footContent.length > 0) { + data.content = data.content + '

' + fnName + '

' + footContent + '
'; + } + return data; +});