From dfe91207af4f3ea100a73ddc7b3f103966e871d0 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 16 Apr 2017 18:29:08 -0400 Subject: [PATCH] Change the pseudomarkdown emphasis to be global and nongreedy --- modules/ui/curtain.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/ui/curtain.js b/modules/ui/curtain.js index 1c31d6ecb..0e79d7f2b 100644 --- a/modules/ui/curtain.js +++ b/modules/ui/curtain.js @@ -51,13 +51,24 @@ export function uiCurtain() { } + /** + * Reveal cuts the curtain to highlight the given box, + * and shows a tooltip with instructions next to the box. + * + * @param {String|ClientRect} [box] box to focus on + * @param {String} [text] text for a tooltip + * @param {Object} [options] + * @param {integer} [options.duration] transition time in milliseconds + * @param {string} [options.buttonText] if set, create a button with this text label + * @param {function} [options.buttonCallback] if set, the callback for the button + */ curtain.reveal = function(box, text, options) { if (typeof box === 'string') box = d3.select(box).node(); if (box && box.getBoundingClientRect) box = copyBox(box.getBoundingClientRect()); options = options || {}; - if (text) { + if (box && text) { // pseudo markdown hacks var parts = text.split('**'); var html = parts[0] ? '' + parts[0] + '' : ''; @@ -66,7 +77,7 @@ export function uiCurtain() { } // pseudo markdown bold text hack - html = html.replace(/\*(.*)\*/, '$1'); + html = html.replace(/\*(.*?)\*/g, '$1'); if (options.buttonText && options.buttonCallback) {