From 6460e5893cabdb7edc1a68be55785cbe96ebc7d1 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 19 Nov 2017 18:47:35 -0500 Subject: [PATCH] minor code review --- src/js/i18n.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/i18n.js b/src/js/i18n.js index e7d1647..c43c295 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -41,7 +41,7 @@ // No HTML entities are allowed, there is code to handle existing HTML // entities already present in translation files until they are all gone. -var reSafeTags = /^([\s\S]*?)<(b|blockquote|code|em|i|span|sup)>(.+?)<\/\2>([\s\S]*)$/, +var reSafeTags = /^([\s\S]*?)<(b|blockquote|code|em|i|kbd|span|sup)>(.+?)<\/\2>([\s\S]*)$/, reSafeInput = /^([\s\S]*?)<(input type="[^"]+")>(.*?)([\s\S]*)$/, reInput = /^input type=(['"])([a-z]+)\1$/, reSafeLink = /^([\s\S]*?)<(a href=['"]https?:\/\/[^'" <>]+['"])>(.+?)<\/a>([\s\S]*)$/, @@ -76,6 +76,8 @@ var safeTextToTagNode = function(text) { return document.createElement('em'); case 'i': return document.createElement('i'); + case 'kbd': + return document.createElement('kbd'); case 'span': return document.createElement('span'); case 'sup': @@ -166,7 +168,9 @@ vAPI.i18n.render = function(context) { uDom('[data-i18n-tip]', context).forEach(function(elem) { elem.attr( 'data-tip', - vAPI.i18n(elem.attr('data-i18n-tip')).replace(/
/g, '\n').replace(/\n{3,}/g, '\n\n') + vAPI.i18n(elem.attr('data-i18n-tip')) + .replace(/
/g, '\n') + .replace(/\n{3,}/g, '\n\n') ); }); };