VishwaKumar
VishwaKumar

Reputation: 3433

How to replace html tags with new line character in jquery + imagemagick?

I am having a contenteditable div. So according to a very good post here html tags are added on enter key press for different browsers. Now i want to replace these with a new line character and send it to imagemagick plugin to create a new line effect. HOw can i do this with jquery on the client side.

I am trying to do this but not getting the result:

messageText1 = $("#templateIframe")
  .contents()
  .find("#dialog")
  .html()
  .replace(/<(?:.|)*?>/gm, '\\n')
  .replace(/&nbsp;/g, '');

alert(messageText1);
messageText = messageText1.replace(/\n{2}/g, '\\n');
alert(messageText1);

Upvotes: 0

Views: 1361

Answers (1)

VishwaKumar
VishwaKumar

Reputation: 3433

Got the solution from this post

messageText = $("#templateIframe")
.contents()
.find("#dialog")
.html()
.replace(/<(?:.|)*?>/gm, '\\n')
.replace(/&nbsp;/g, '')
.replace(/\\n\\n/g,"\\n");

alert(messageText);

Upvotes: 1

Related Questions