summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-02-11 14:45:41 +0200
committerAlon Levy <alon@pobox.com>2015-02-11 14:45:41 +0200
commit6746a8fd949c401e5b2c1b00f3a7f69a3c209f36 (patch)
tree1d31b27674c3c5694160f280375b8cbb70be7f1b
parent0dc89aa6b16412b02d76151a777c2346409bb78f (diff)
client/textanalysis: sanitize quotes, fixes #293
-rw-r--r--res/client/css/style.css13
-rw-r--r--src/client/textanalysis.js13
2 files changed, 16 insertions, 10 deletions
diff --git a/res/client/css/style.css b/res/client/css/style.css
index 531b15c6..63893106 100644
--- a/res/client/css/style.css
+++ b/res/client/css/style.css
@@ -49,9 +49,6 @@ a:hover {
a:active {
color: #919095; }
-button {
- border: none; }
-
input {
background-color: white;
color: #363636;
@@ -439,7 +436,7 @@ body.debug .debug-ui-right {
fill: #8b3ab0; }
.circle.project {
- fill: #40C200; }
+ fill: #40c200; }
.circle.third-internship-proposal {
fill: #33c2e0; }
@@ -680,7 +677,7 @@ body.debug .debug-ui-right {
border-top: 6px solid #363636; }
.info.type-project {
- border-top: 6px solid #40C200; }
+ border-top: 6px solid #40c200; }
.info .info-card-attr {
display: block;
@@ -760,8 +757,8 @@ body.debug .debug-ui-right {
width: 100%;
min-height: 48px;
text-align: center;
- background-color: #D3F2F8;
- color: #1D6E7F;
+ background-color: #d3f2f8;
+ color: #1d6e7f;
border-top: 1px solid #8eb6bf;
border-bottom: 1px solid #8eb6bf; }
@@ -986,5 +983,3 @@ p {
svg text::selection {
background: none; }
-
-/*# sourceMappingURL=style.css.map */
diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js
index e0b57dbc..9a4cd412 100644
--- a/src/client/textanalysis.js
+++ b/src/client/textanalysis.js
@@ -28,6 +28,17 @@ function selectedType()
return nodetypes[typeindex];
}
+/*
+ * Place to do general cleanup of the text. Right now just replacing all quotation types
+ * with a single type, separately for double quotes and single quotes.
+ */
+function cleanup(text)
+{
+ return text
+ .replace(/[״”“„‟″‶]/, '"') // Convert typographic double quotes
+ .replace(/[`׳’‘‚‛′‵]/, "'"); // Convert typographic single quotes
+}
+
/**
* Tokenizer for input.
*
@@ -251,7 +262,7 @@ var textAnalyser = function (spec) {
//Sentence Sequencing
//Build the words and cuts the main elements
- tokens = tokenize(newtext, '#', '"');
+ tokens = tokenize(cleanup(newtext), '#', '"');
sentence = tokens.map(function (d) { return d.token; });
// build new node,link arrays in order of appearance