Skip to content

Instantly share code, notes, and snippets.

@derekjohnson
Last active December 14, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekjohnson/5039415 to your computer and use it in GitHub Desktop.
Save derekjohnson/5039415 to your computer and use it in GitHub Desktop.
Add markers to text to easily see line length when prototyping layouts.
(function(doc){
if(doc.querySelectorAll) { // This only works in IE 8+
var copy = doc.querySelectorAll('.string') // Element(s) with class="string" need to be in markup
, i = 0
, ii = copy.length
, replace_at = function(text, index, char) {
return text.substr(0, index) + char + text.substr(index + 1);
}
;
for(i; i<ii; i++) {
var text = copy[i].textContent;
text = replace_at(text, 44, '^'); // Replace 45th char with asterisk
text = replace_at(text, 71, '$'); // Replace 72nd char with caret
text = replace_at(text, 66, '*'); // Replace 66th char with asterisk
copy[i].textContent = text;
}
}
})(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment