Permalink
Browse files

New option: trim. If 'simple', trims all preceding and following whit…

…espace. If 'advanced', does what it previously did. Defaults to 'simple'.
  • Loading branch information...
1 parent 6345f55 commit 83d260dc601b8be58c7878e0c10bb09cbe3a3e53 @sorccu committed Apr 2, 2010
Showing with 6 additions and 4 deletions.
  1. +6 −4 js/cufon.js
View
@@ -228,7 +228,8 @@ var Cufon = (function() {
'run-in': 1
};
var wsStart = /^\s+/, wsEnd = /\s+$/;
- return function(text, style, node, previousElement) {
+ return function(text, style, node, previousElement, simple) {
+ if (simple) return text.replace(wsStart, '').replace(wsEnd, '');
if (previousElement) {
if (previousElement.nodeName.toLowerCase() == 'br') {
text = text.replace(wsStart, '');
@@ -617,7 +618,7 @@ var Cufon = (function() {
function replaceElement(el, options) {
var name = el.nodeName.toLowerCase();
if (options.ignore[name]) return;
- var replace = !options.textless[name];
+ var replace = !options.textless[name], simple = (options.trim === 'simple');
var style = CSS.getStyle(attach(el, options)).extend(options);
// may cause issues if the element contains other elements
// with larger fontSize, however such cases are rare and can
@@ -639,7 +640,7 @@ var Cufon = (function() {
}
if (anchor) {
el.replaceChild(process(font,
- CSS.whiteSpace(anchor.data, style, anchor, lastElement),
+ CSS.whiteSpace(anchor.data, style, anchor, lastElement, simple),
style, options, node, el), anchor);
anchor = null;
}
@@ -717,7 +718,8 @@ var Cufon = (function() {
tr: 1,
ul: 1
},
- textShadow: 'none'
+ textShadow: 'none',
+ trim: 'simple'
};
var separators = {

0 comments on commit 83d260d

Please sign in to comment.