- AuthorPosts
- November 11, 2008 at 3:42 am #6562nickbMember
Hello,
Anyone with a macro script to convert plain text (with urls) into html code?
example:
http://www.google.com/ searchengine
http://www.emeditor.com/ text editor
…gr. :-)
November 12, 2008 at 1:31 am #6566webernMemberA basic example. Apply it only for selected text.
with (document.selection){
var STR = Text;
if (!IsEmpty){
var mud = "";
var endPos =0 ;
endPos = STR.lastIndexOf("<");
if (endPos!=-1){
mud = STR.substr(endPos);
STR = STR.substr(0,endPos);
Text = '<a href="' + STR + '" target="blank">' + STR + '</a>' + mud;
} else Text = '<a href="' + STR + '" target="blank">' + STR + '</a>' + "<br>";
}
}November 15, 2008 at 1:53 am #6599nickbMemberThank you for the basic script, webern
I like the way you can copy an url an use it as the anchor. This script is usefull if you have to convert 1 url, because you have to select this first. But for a list in this format it will not work….
http://www.google.com/ searchengine
http://www.emeditor.com/ text editor
…November 15, 2008 at 4:17 am #6601webernMembernickb
see PMNovember 16, 2008 at 12:28 pm #6612dreftymacParticipantYou might want to try a script that is designed for this purpose. One example is txt2tags.
November 16, 2008 at 7:56 pm #6614nickbMemberimpressive script :-)
Personally I use http://virdi-software.com/txt2web/ to create the base for my html pages. But I want to convert a simple page by using a macro in the Emeditor environment. Macros are easy to adjust and to combine with other macros.November 16, 2008 at 8:54 pm #6615dreftymacParticipantThat makes sense. Just as a reminder (to others who may read this, in case you already know) EmEditor allows you to create a macro that runs an external script as well. This is a built-in feature of windows scripting host.
You can mix EmEditor macro code with the code that someone else has written so that you never have to leave the editor to do anything you want. This means you never actually have to write custom code (ulness you prefer to do so of course).
This aspect of EmEditor (direct support for windows scripting host) is really powerful, and as far as I have seen, unique for windows editors. Even editors that support macro scripting don’t usually integrate with the windows scripting host.
It does get a little tricky if you try to use Ruby or Python ActiveScript engines, but the built-in javascript and vbscript support seems to work very well.
November 17, 2008 at 8:04 pm #6624nickbMemberSounds very interesting.
I’m not a programmer, so I work most of time with macros (easy to use).
If someone knows a good tutorial or examples related to this function, please post!Thx dreftymac for pointing me to this one. :-)
November 18, 2008 at 2:53 am #6625dreftymacParticipantAlthough this is not an example of converting html, it is an introduction to the “Run” feature of the windows scripting host:
var shell = new ActiveXObject(“WScript.Shell”);
shell.Run(“”C:Program FilesInternet ExplorerIExplore.exe”http://www.emeditor.com”);This example will work on most systems to open MSIE. You can paste this into an EmEditor macro file and run it. The important point is that all macros in EmEditor are also scripts that you can run in regular Windows. This is useful because it means anything you can do from Windows, you can do it from inside EmEditor also.
An example for converting html could be to create a macro that runs HTMLTidy against the currently-focused document in EmEditor, where you just pass the path to HTMLTidy and the path of the current document to EmEditor.
For those who are not programmers, but willing to learn a little bit about Windows Scripting in order to get more out of EmEditor macros, a good thing to try is a search on your favorite search engine:
“What is WSH”
or
“What is Windows Scripting Host”
If you are familiar with EmEditor macros, you are already familiar with WSH, so you may want to take a moment to read some of the tutorials and the reference from Microsoft.
http://cwashington.netreach.net/
http://msdn.microsoft.com/en-us/library/98591fh7.aspxNovember 20, 2008 at 8:41 am #6639nickbMemberThanks again, dreftymac. I really appreciate your help. :-)
- AuthorPosts
- You must be logged in to reply to this topic.