Created
August 28, 2010 22:59
-
-
Save jarmo/555681 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/common/src/js/bot/dom.js b/common/src/js/bot/dom.js | |
index 0ec37dd..600e136 100644 | |
--- a/common/src/js/bot/dom.js | |
+++ b/common/src/js/bot/dom.js | |
@@ -365,7 +365,7 @@ bot.dom.getVisibleText = function(node) { | |
if (nodeText.length) { | |
if (bot.dom.isClosestAncestorBlockLevel_(elements, i)) { | |
returnValue += '\n'; | |
- } else if (i != 0) { // First element does not need preceding space. | |
+ } else if (i != 0 && !nodeText[0].match(/[,.:;?!%]/)) { // First element and some symbols do not need preceding space. | |
returnValue += ' '; | |
} | |
} | |
diff --git a/common/test/js/bot/text_test.html b/common/test/js/bot/text_test.html | |
index 21d356c..bc195b1 100644 | |
--- a/common/test/js/bot/text_test.html | |
+++ b/common/test/js/bot/text_test.html | |
@@ -134,6 +134,11 @@ limitations under the License. | |
assertEquals("line has text", text); | |
} | |
+ function testGetVisibleTextShouldNotAddExtraSpacesBeforeSomeCharacters() { | |
+ var text = getVisibleTextByElementId("descartes"); | |
+ assertEquals("Dubito, ergo cogito, ergo sum.", text); | |
+ } | |
+ | |
function testGetVisibleTestGetTextWithLineBreakForInlineElement() { | |
var text = getVisibleTextByElementId("label1"); | |
assertContains("foo\nbar", text); | |
@@ -219,6 +224,8 @@ limitations under the License. | |
<div id="collapsingtext"><span></span><div>Hello, world</div><span></span></div> | |
+ <span><strong id="descartes">Dubito, <em>ergo cogito</em>, ergo sum.</strong></span> | |
+ | |
<form action="resultPage.html"> | |
<p> | |
<input type="checkbox" id="checkbox1"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment