text to html conversion

Discussion in 'HTML' started by Yashwant, Nov 17, 2005.

  1. Yashwant

    Yashwant Guest

    I want some information and documentation about how to convert text to
    html using java? can anyone please help..
     
    Yashwant, Nov 17, 2005
    #1
    1. Advertising

  2. Yashwant wrote:
    > I want some information and documentation about how to convert text to
    > html using java? can anyone please help..
    >

    Google JSP (java server pages) and/or Tomcat if you want it
    done on the fly. I guess there are other options still.
    If you just want to create html files as such, I don't see
    what special instruction you could use. Grab the text, add
    html tags and write into a file.
     
    Mitja Trampus, Nov 17, 2005
    #2
    1. Advertising

  3. Yashwant

    Andy Dingley Guest

    On 17 Nov 2005 12:51:49 -0800, "Yashwant" <> wrote:

    >I want some information and documentation about how to convert text to
    >html using java?


    1) What are you trying to do ? A one-off conversion, with maybe an
    update every few weeks or is this a continuing dynamic task ?

    2) Why Java ? There are lots of techniques out there, don't tie
    yourself into a particular one before you're forced to.

    3) What is "text" ? Is this simply plain text? Does it have paragraph
    breaks in it (such as a blank line)? Or does it have some attempt at
    full formatting in it?


    If this was a one-off, then I'd probably do it with Perl because it's
    simple and convenient. In the simplest case you just need to write out a
    standard header and footer (probably best to read this from a template
    file) and then insert the text file into the middle of it. You use Perl
    rather than SSI because there's probably a regex in there that
    recognises a blank line and turns it into </p><p> markup.

    If it's a dynamic case, then look at what you can get hosted on the
    server you need to use. This is more likely to be PHP than Java and the
    problem is so trivial that you could do it with any server-side
    scripting tool.
     
    Andy Dingley, Nov 17, 2005
    #3
  4. Yashwant

    Sid Ismail Guest

    On 17 Nov 2005 12:51:49 -0800, "Yashwant" <>
    wrote:

    : I want some information and documentation about how to convert text to
    : html using java? can anyone please help..
    :



    http://www.cybermatrix.com/txt2html.html
    Maybe this is what you want?

    Sid
     
    Sid Ismail, Nov 17, 2005
    #4
  5. Yashwant

    Toby Inkster Guest

    Yashwant wrote:

    > I want some information and documentation about how to convert text to
    > html using java?


    My Java is a little rusty, but...

    class TextToHTML
    {
    private String starttag = "\n<pre>";
    private String finaltag = "</pre>\n";

    public String convert (String text)
    {
    String html;

    html = text.replaceAll("&", "&amp;");
    html = html.replaceAll("<", "&lt;");

    return starttag + html + finaltag;
    }
    }

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Nov 18, 2005
    #5
  6. Yashwant

    Toby Inkster Guest

    Andy Dingley wrote:

    > You use Perl rather than SSI because there's probably a regex in there
    > that recognises a blank line and turns it into </p><p> markup.


    s/^\s*$/<\/p><p>/g;

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Nov 18, 2005
    #6
  7. Yashwant

    Jim Higson Guest

    Toby Inkster wrote:

    > Andy Dingley wrote:
    >
    >> You use Perl rather than SSI because there's probably a regex in there
    >> that recognises a blank line and turns it into </p><p> markup.

    >
    > s/^\s*$/<\/p><p>/g;
    >


    Except the g probably isn't needed, unless you need the abilty to detect
    more than one blank line per line :)
     
    Jim Higson, Nov 18, 2005
    #7
  8. Yashwant

    Toby Inkster Guest

    Jim Higson wrote:

    > more than one blank line per line :)


    It's a possibility. ;-)

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Nov 18, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. osiceanu
    Replies:
    4
    Views:
    331
    Mark Rae [MVP]
    Feb 21, 2008
  2. , India
    Replies:
    2
    Views:
    479
    Fraser Ross
    Sep 15, 2009
  3. leo
    Replies:
    1
    Views:
    290
    Bob Lehmann
    Dec 5, 2005
Loading...

Share This Page