in reply to Converting custom mark-up to HTML
This gives the following output (which I think is what you want):#!/usr/bin/perl use strict; use warnings; $/ = undef; my $text = <DATA>; $text =~ s!\[color=([^\]]+)\](.*?)\[/color\]!<font color="$1">$2</font +>!gi; $text =~ s!\[image=([^\]]+)\]!<img src="$1">!gi; $text =~ s!\[link=([^\]]+)\](.*?)\[/link\]!<a href="$1">$2</a>!gi; print $text; __DATA__ [color=#0000ff]Blue text[/color] with an image: [image=var.jpg] And a link to Google: [link=http://www.google.com]Google[/link].
<font color="#0000ff">Blue text</font> with an image: <img src="var.jp +g"> And a link to Google: <a href="http://www.google.com">Google</a>.
Arjen
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Converting custom mark-up to HTML
by bkiahg (Pilgrim) on Apr 19, 2004 at 17:52 UTC | |
by Aragorn (Curate) on Apr 19, 2004 at 18:32 UTC |