EmEditor (text editor) Forum Index Macro Samples
inster HTML tag | Register To Post |
| Flat | Previous Topic | Next Topic |
| 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; } })(); |
| Flat | Previous Topic | Next Topic |
| Subject | Poster | Date |
|---|---|---|
| » |
robben | 11/23/2009 6:43 pm |
| |
horatio | 2/2/2010 12:16 am |
| Register To Post | |


