Home
Virtual Image Printer DriverMiraplacid Publisher converts documents to images
Virtual Text Printer DriverMiraplacid Text Driver extracts text from documents
Miraplacid Data ViewerMiraplacid Data Viewer - access to internal structure of a binary file
Miraplacid Text ViewerMiraplacid Text Viewer - access to internal structure of a text file
Common:   Login | Rules of forum | Register
Management:  New topic | Close topic | Move topic | Delete topic
  

Miraplacid Forum >> Software Development >> convert text to htmlModerator:XMan

Author Topic:  convert text to html
Stephen Anderson
Member

From: Denmark
posted 2004-04-03 07:47:50 Reply -Delete

I have links like
http://www.yahoo.com
http://www.google.com
...

I need to convert them to

http://www.yahoo.com

http://www.google.com
...

in the beginning it was Ok to process them manually, but now I just have too many of them

stephany
Member

From: US
posted 2004-04-05 04:31:29 Reply -Delete

Here we go.

Put your urls to file 1.txt and start this perl script

$fn1="1.txt";
$fn2="1.htm";

open(FILE,"<$fn1");
open(OFILE,">$fn2");

foreach $a () {
chomp($a);
print OFILE "\n";
}

close(FILE);
close(OFILE);

jn
Member

From: Norway
Email
posted 2004-04-06 04:22:28 Reply -Delete

I write it on JScript

var argv = WScript.Arguments;
if (argv.length<2) {
WScript.echo("File Names Required");
WScript.Quit();
}
var n_from=argv(0);
var n_to=argv(1);

function process() {
while (!from.AtEndOfStream) {
line=from.ReadLine();
r.Write("\n");
}
}

var fso, r;
fso = new ActiveXObject("Scripting.FileSystemObject");
var from = fso.OpenTextFile(n_from, 1);
r = fso.CreateTextFile(n_to, true);

process();

r.Close();
from.Close();

jn
Member

From: Norway
Email
posted 2004-04-06 04:24:10 Reply -Delete

It seems the HTM ate my < and >
Let's try again.

var argv = WScript.Arguments;
if (argv.length<2) {
WScript.echo("File Names Required");
WScript.Quit();
}
var n_from=argv(0);
var n_to=argv(1);

function process() {
while (!from.AtEndOfStream) {
line=from.ReadLine();
r.Write("<a href=\""+line+"\">"+line+"<a>\n");
}
}

var fso, r;
fso = new ActiveXObject("Scripting.FileSystemObject");
var from = fso.OpenTextFile(n_from, 1);
r = fso.CreateTextFile(n_to, true);

process();

r.Close();
from.Close();

stephany
Member

From: US
posted 2004-04-06 08:32:05 Reply -Delete

Damn! Same problem!

$fn1="1.txt";
$fn2="1.htm";

open(FILE,"<$fn1");
open(OFILE,">$fn2");

foreach $a (<FILE>) {
chomp($a);
print OFILE "<a href=\"$a\">$a</a>\n";
}

close(FILE);
close(OFILE);

Barbara
Member

From: AU
posted 2004-04-07 11:51:04 Reply -Delete

Same thing on C# :)

using System;
using System.IO;
using System.Text.RegularExpressions;

namespace Barbara
{
public class xapp
{
const String fn_in="1.txt";
const String fn_out="1.htm";
FileStream xin;
FileStream xout;
public static void Main()
{
xapp app=new xapp();
}
public xapp() {
xin = new FileStream(fn_in, FileMode.Open, FileAccess.Read);
xout = new FileStream(fn_out, FileMode.Create, FileAccess.Write);
StreamReader sr = new StreamReader(xin);
StreamWriter sw = new StreamWriter(xout);

process(sr,sw);

sr.Close();
sw.Close();
xin.Close();
xout.Close();
}
// The Processing Routine
public void process(StreamReader sr,StreamWriter sw) {
string line;
while (null!=(line=sr.ReadLine())) {
sw.WriteLine("<a href=\""+line+"\">"+line+"</a>\n");
}
}
}
}

Your message:
Name, password:
Go to category:  

Technical Support

Copyright © Miraplacid, 2003 - 2019