Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #6562
    nickb
    Member

    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. :-)

    #6566
    webern
    Member

    A 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>";
    }
    }
    #6599
    nickb
    Member

    Thank 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

    #6601
    webern
    Member

    nickb
    see PM

    #6612
    dreftymac
    Participant

    You might want to try a script that is designed for this purpose. One example is txt2tags.

    http://en.wikipedia.org/wiki/Txt2tags

    #6614
    nickb
    Member

    impressive 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.

    #6615
    dreftymac
    Participant

    That 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.

    #6624
    nickb
    Member

    Sounds 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. :-)

    #6625
    dreftymac
    Participant

    Although 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&#8221;);

    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.aspx

    #6639
    nickb
    Member

    Thanks again, dreftymac. I really appreciate your help. :-)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.