Gossamer Forum
Home : Products : DBMan : Customization :

[b ] [/b ] then bold

Quote Reply
[b ] [/b ] then bold
Hi this is the new solution, if some adding info then he want to bold his wrod by typing
word then his word turn to "word".
word then his word turn to "word".
word then his word turn to "word".
Could any one sample me by post the code on this thread,please answer me with the code cos' It easy for me to understand it I can not do it myself.
refer to:http://gossamer-threads.com/perl/forum/showflat.pl?Cat=&Board=L2Cust&Number=48687&page=&view=&sb=&vc=1
Any help 'd be GREAT appriciated.
Regards,
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
For bold:

$rec{'FIELD'} =~ s/\[b\](.+)\[\/b\]/<b>$1<\/b>/g;

For colored text:

$rec{'FIELD'} =~ s/\[red\](.+)\[\/red\]/<font color=\"#FF3333\">$1<\/font>/g;

Get the idea?

Let me know if those codes don't work because I haven't tested them.

They can probably be made shorter too.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: [b ] [/b ] then bold In reply to
Just missing a slash:

$rec{'FIELD'} =~ s/\[b\](.+)\[\/b\]/<b>$1<\/b>/g;

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: [b ] [/b ] then bold In reply to
Thank you Mark,Paul :-)
It is work!!but Just missing a slash for color aswell.
$rec{'Info'} =~ s/\[blue\](. )\[\/blue\]/<font color=\"#3366FF\">$1<\/font>/g;

Then now I add code below to hyperlink email address and url ,


$rec{'Info'} =~ s/([\w] :\/\/[\w-?&;#~=\.\/] [\w])/<A HREF="$1" target=\"new\">$1<\/A>/g;
$rec{'Info'} =~ s/(mailto:[\w-?@&;#~=\.\/] [\w])/<A HREF="$1" target=\"new\">$1<\/A>/g;

I ever also added the smile mod before (by Mark also) then all the image not show fine after add above 2 lines. see smile mod code below please.

In default.cfg add the following:


# URL to the directory with the smile images:
$smile_url = 'http://www.myserver.com/images/smiles/';
# Add each smile as 'smile-code','image':
@smiles = (
':)','smile.gif',
';)','wink.gif',
':(','sad.gif'
);
Then, at the top of html_record, under the line my %rec = @_;, add the following:


for ($i = 0; $i < scalar(@smiles); $i = $i 2) { $rec{'Info'} =~ s/\Q$smiles[$i]\E/<img src="$smile_url$smiles[$i 1]">/g;}


Image turn to something .... please see html that show image below;
<img src="<A HREF="'http://www.myserver.com/images/smiles/CousinVince.gif" target="new">'http://www.myserver.com/images/smiles/CousinVince.gif</A>">

q: how to fix this image mod error?
May be I will try
change
$smile_url = 'http://www.myserver.com/images/smiles/';
with this
$smile_url = '/images/smiles/';

Love you all,and thank fo rthis great forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
wOW! WORK! :-)
Thank you MARK AND PAUL ;-))))


Love you all,and thank fo rthis great forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Then back to the beginning again ,I successed with them and add below code in sub html_record_long;
$rec{'Info'} =~ s/\[b\](. )\[\/b\]/<b>$1<\/b>/g;
$rec{'Info'} =~ s/\[red\](. )\[\/red\]/<font color=\"#FF3333\">$1<\/font>/g;


But I don't need it in sub html_record cos' it will mess my short view out of control...hmm so how to fix this problem?

In short view it show Info like this,
such as blabla [h1 ]blabla[/h1 ] blabla
I want to get rid of [.. ] and [/...]



Love you all,and thank fo rthis great forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Then put it in the sub html_record_long routine.

Regards,

Eliot Lee
Quote Reply
Re: [b ] [/b ] then bold In reply to
Hi,Eliot ;)
No I not mean to bold or color text anymore in short view,so i dont put the same code in html_record .But I need it removed.cos' I have something like [h1 ]blabla[/h1 ] but i dont want them so it need them removed.


Love you all,and thank fo rthis great forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Try: $rec{'FIELD'} =~ s/\[[^\]]+\]//g; in sub html_record

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: [b ] [/b ] then bold In reply to
Great!!I t work Mark ,Thank you very much and also thank to Eliot and Paul.


Love you all,and thank for all help here ,this is a greatest forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Hi after modified and use this mod, I see a mistake.
Please see the sample;
if i type
texttexttexttext_ENTER_ONCE_texttext[/ red]
the result is
texttexttexttexttexttext[/ red]
I see the and [/ red] not change text color to what it should be.
This happen for every expression if I press enter to make a breakline between regular expression.

Cuold any one help me please.


Love you all,and thank for all help here ,this is a greatest forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Try using "m"

$rec{'FIELD'} =~ m/\[b\](.+)\[\/b\]/<b>$1<\/b>/g;



Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: [b ] [/b ] then bold In reply to
No, it is not work, i got many error if change s to m.

Love you all,and thank for all help here ,this is a greatest forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Try:
$rec{'Info'} =~ s/\[b\]([^\]]+)\[\/b\]/<b>$1<\/b>/g;
$rec{'Info'} =~ s/\[red\]([^\]]+)\[\/red\]/<font color=\"#FF3333\">$1<\/font>/g;


And place it above the line which converts enters to <BR>s.

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Post deleted by AstroBoy In reply to
Quote Reply
Re: [b ] [/b ] then bold In reply to
HI, Mark :-)
the code you gave works!! with bold and color but not work with these expressions;
$rec{'Info'} =~ s/\[u\](.+)\[\/u\]/<u>$1<\/u>/g;
$rec{'Info'} =~ s/\[i\](.+)\[\/i\]/<i>$1<\/i>/g;
$rec{'Info'} =~ s/\[s\](.+)\[\/s\]/<s>$1<\/s>/g;
$rec{'Info'} =~ s/\[sub\](.+)\[\/sub\]/<sub>$1<\/sub>/g;
$rec{'Info'} =~ s/\[sup\](.+)\[\/sup\]/<sup>$1<\/sup>/g;
$rec{'Info'} =~ s/\[center\](.+)\[\/center\]/<center>$1<\/center>/g;
$rec{'Info'} =~ s/\[list\](.+)\[\/list\]/<ul>$1<\/ul>/g;
$rec{'Info'} =~ s/\[li\]/<li>/g;
$rec{'Info'} =~ s/\[hr\]/<hr>/g;
$rec{'Info'} =~ s/\[h1\](.+)\[\/h1\]/<h1>$1<\/h1>/g;
$rec{'Info'} =~ s/\[h2\](.+)\[\/h2\]/<h2>$1<\/h2>/g;
$rec{'Info'} =~ s/\[h3\](.+)\[\/h3\]/<h3>$1<\/h3>/g;

sample: if I type
[ h2] texttext_THEN_ENTER_texttext[ /h2]
the result will be like this,
[ h2] texttexttexttext[ /h2]
I dont know why [ h2][ /h2] keep showing ,I try change to $rec{'Info'} =~ s/\[u\]([^\]]+)\[\/u\]/<u>$1<\/u>/g;
$rec{'Info'} =~ s/\[i\]([^\]]+)\[\/i\]/<i>$1<\/i>/g;
$rec{'Info'} =~ s/\[s\]([^\]]+)\[\/s\]/<s>$1<\/s>/g;
$rec{'Info'} =~ s/\[sub\]([^\]]+)\[\/sub\]/<sub>$1<\/sub>/g;
$rec{'Info'} =~ s/\[sup\]([^\]]+)\[\/sup\]/<sup>$1<\/sup>/g;
$rec{'Info'} =~ s/\[center\]([^\]]+)\[\/center\]/<center>$1<\/center>/g;
$rec{'Info'} =~ s/\[list\]([^\]]+)\[\/list\]/<ul>$1<\/ul>/g;
$rec{'Info'} =~ s/\[li\]/<li>/g;
$rec{'Info'} =~ s/\[hr\]/<hr>/g;
$rec{'Info'} =~ s/\[h1\]([^\]]+)\[\/h1\]/<h1>$1<\/h1>/g;
$rec{'Info'} =~ s/\[h2\]([^\]]+)\[\/h2\]/<h2>$1<\/h2>/g;
$rec{'Info'} =~ s/\[h3\]([^\]]+)\[\/h3\]/<h3>$1<\/h3>/g;
and test it again,adding breakline by enter it will not work.!!




Love you all,and thank for all help here ,this is a greatest forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
If

$rec{'Info'} =~ s/\[b\]([^\]]+)\[\/b\]/<b>$1<\/b>/g;
$rec{'Info'} =~ s/\[red\]([^\]]+)\[\/red\]/<font color=\"#FF3333\">$1<\/font>/g;

It work if i follow this format text
But not work if like this,text the incorrect result,text

Love you all,and thank for all help here ,this is a greatest forum.
Act.
Quote Reply
Re: [b ] [/b ] then bold In reply to
Hi,

This works for me...

Code:
$rec{'Info'} =~ s/\[red\]/<font color="#FF3333">/gi;
$rec{'Info'} =~ s/\[\/red\]/<\/font>/gi;
$rec{'Info'} =~ s/\[b\]/<b>/gi;
$rec{'Info'} =~ s/\[\/b\]/<\/b>/gi;
Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: [b ] [/b ] then bold In reply to
Work like a charm!! :)))

Love you all,and thank for all help here ,this is a greatest forum.
Act.