Permalink
Browse files

Allow hyphen -> en dash conversions at the ends of lines.

  • Loading branch information...
1 parent bb50d17 commit 8309a9d3cf3a8d311d41fa088c28033a06d25086 @chanks committed Jan 18, 2012
Showing with 15 additions and 10 deletions.
  1. +5 −0 test/cases/parse_line.js
  2. +9 −9 texticle.coffee
  3. +1 −1 texticle.js
View
@@ -66,6 +66,11 @@ parse_line = [
'textile' : "- This lets me list my thoughts more clearly.",
'html' : "– This lets me list my thoughts more clearly."
},
+ {
+ 'name' : "A hyphen at the end of a line will be converted to an en dash.",
+ 'textile' : "Dearest Dr. Darcy -",
+ 'html' : "Dearest Dr. Darcy –"
+ },
View
@@ -1,14 +1,15 @@
window.Texticle = {}
entities =
- "\\.\\.\\." : "…"
- "--" : "—"
- "\\([Cc]\\)" : "©"
- "\\([Rr]\\)" : "®"
- "\\((TM|tm)\\)" : "™"
- "'" : "’"
- "(^|\\s)\"" : "$1“"
- "\"(\\s|$)" : "”$1"
+ "\\.\\.\\." : "…"
+ "(^|\\s)-(\\s|$)" : "$1–$2"
+ "--" : "—"
+ "\\([Cc]\\)" : "©"
+ "\\([Rr]\\)" : "®"
+ "\\((TM|tm)\\)" : "™"
+ "'" : "’"
+ "(^|\\s)\"" : "$1“"
+ "\"(\\s|$)" : "”$1"
tags =
"\\*\\*" : 'b'
@@ -31,7 +32,6 @@ for own glyph, tag of tags
Texticle.parse_line = (input) ->
input = input.replace /([\d\s'"])x(?=[\d\s])/g, "$1#215;"
- input = input.replace /^-\s|(\s)-\s/g, "$1– "
for own format, regex of entity_regexes
input = input.replace regex, format
View
@@ -6,6 +6,7 @@
entities = {
"\\.\\.\\.": "…",
+ "(^|\\s)-(\\s|$)": "$1–$2",
"--": "—",
"\\([Cc]\\)": "©",
"\\([Rr]\\)": "®",
@@ -45,7 +46,6 @@
Texticle.parse_line = function(input) {
var format, regex;
input = input.replace(/([\d\s'"])x(?=[\d\s])/g, "$1#215;");
- input = input.replace(/^-\s|(\s)-\s/g, "$1– ");
for (format in entity_regexes) {
if (!__hasProp.call(entity_regexes, format)) continue;
regex = entity_regexes[format];

0 comments on commit 8309a9d

Please sign in to comment.