EmEditor (text editor) Forum Index
   Macro Samples
     inster HTML tag
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
robben
Posted on: 11/23/2009 6:43 pm
Not too shy to talk
Joined: 5/1/2009
From:
Posts: 33
inster HTML tag
(function() {
var word = document.selection.Text;
var tag=prompt( "start_tag", "p" );
//var end_tag=prompt( "end_tag", "p" );
if (!tag) return;
var start_tag="<"+tag+">";
var end_tag="</"+tag+">";
if (word == '') {
document.selection.SelectLine();
var str = document.selection.Text;
if (str.replace(/\s/g, '') == '') {
str = str.replace(/[\r\n]*/g, '');
document.selection.Text = str;
return;
}
else {
str = str.replace(/[\r\n]*/g, '');
str = str.replace(/^([\s]*)([\w\W]+)/, '$1' + start_tag + '$2' + end_tag + '\r\n');
var cp = str.indexOf(start_tag);
document.selection.Text = str;
document.selection.CharLeft(false, str.length - cursorFix);
document.selection.StartOfLine();
document.selection.CharRight(false, cp + start_tag.length);
return;
}
}
else {
word = start_tag + word.replace(/\r*\n/g, end_tag + '\r\n' + start_tag) + end_tag;
document.selection.Text = word;
return;
}

})();

horatio
Posted on: 2/2/2010 12:16 am
Just popping in
Joined: 2/2/2010
From:
Posts: 1
Re: inster HTML tag
EmEditor Macro Error:

Expected ';'

File: [path]

Line: 1
Threaded | Newest First Previous Topic | Next Topic | Top


Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文