Permalink
Browse files

Incorporated "auto-indent bug in Chrome" fix from ChadBurggraf/wmd (v…

…ia polestarsoft/wmd)
  • Loading branch information...
1 parent 75a7c6c commit 58e196be8bce93373ef05361e20177c248c3779e @ChiperSoft committed Jan 27, 2011
Showing with 12 additions and 5 deletions.
  1. +1 −1 License.txt
  2. +11 −4 wmd.js
View
2 License.txt
@@ -2,7 +2,7 @@ The MIT License
Original WMD and Showdwon code copyright (c) 2007 John Fraser
Modifications and bugfixes (c) 2009-2010 Chris Jester-Young, Dana Robinson, Anand Chitipothu
-Further modifications (c) 2010-2011 Jarvis Badgley, Wenqiang Wang, Helder Ribeiro
+Further modifications (c) 2010-2011 Jarvis Badgley, Wenqiang Wang, Helder Ribeiro, Chad Burggraf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
15 wmd.js
@@ -673,14 +673,21 @@
var regexText;
var replacementText;
+ // New bug discovered in Chrome, which appears to be related to use of RegExp.$1
+ // Hack it to hold the match results. Sucks because we're double matching...
+ var match = /(^\n*)/.exec(this.selection);
+
this.selection = this.selection.replace(/(^\n*)/, "");
- this.startTag = this.startTag + re.$1;
+ this.startTag = this.startTag + (match ? match[1] : "");
+ match = /(\n*$)/.exec(this.selection);
this.selection = this.selection.replace(/(\n*$)/, "");
- this.endTag = this.endTag + re.$1;
+ this.endTag = this.endTag + (match ? match[1] : "");
+ match = /(^\n*)/.exec(this.startTag);
this.startTag = this.startTag.replace(/(^\n*)/, "");
- this.before = this.before + re.$1;
+ this.before = this.before + (match ? match[1] : "");
+ match = /(\n*$)/.exec(this.endTag);
this.endTag = this.endTag.replace(/(\n*$)/, "");
- this.after = this.after + re.$1;
+ this.after = this.after + (match ? match[1] : "");
if (this.before) {

0 comments on commit 58e196b

Please sign in to comment.