From 51e3c481809473762047d7bd7685b77652095864 Mon Sep 17 00:00:00 2001 From: Maurizio Monge Date: Sun, 20 Dec 2015 19:35:36 -0200 Subject: [PATCH] fixed tiny bug in case of empty string that evalulated to false and was triggering an error message. --- README.md | 2 +- kanjax/kanjax.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f7dbf5..6450138 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This project provides a script that searches all kanji's in a web page, adding a clickable link on all kanjis appearing on a web page. You can display the result on -[this page](http://im.ufrj.br/~maurizio.monge/kanjax/test.html) +[this page](http://im.ufrj.br/~maurizio.monge/kanjax/test.html). This library was inspired by MathJax, that automatically formats mathematical formulas in web pages. diff --git a/kanjax/kanjax.js b/kanjax/kanjax.js index 1b5c19f..1bc9a74 100644 --- a/kanjax/kanjax.js +++ b/kanjax/kanjax.js @@ -44,7 +44,10 @@ KanJax = { content = KanJax.popupContent.replace( /\{\{(\w+)\}\}/g, function(match, key) { - return info[key] || ("{unknown field "+key+"}"); + if(key in info) + return info[key] + else + return "{unknown field "+key+"}"; }); div.innerHTML = content;