MySQL highlighter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

how would i make the pattern so the code to be highlighted can be found in between the lines?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Jcart wrote:

Code: Select all

SELECT `answer` FROM `jcart` LIMIT 1
You thought right
:rofl:
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

no, i meant in preg_replace, what should i put as the pattern so my highlighter scans all words in the inputed code.

in geshi, i tried to alter the code, but it's so confusing, because it uses different classes, and functions so much
trying to follow what the code is saying makes my head go :madblow:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

pass an array of patterns and an array of replacements
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

nevermind, i was reading pattern syntax and i got it :D
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

i didn't need to do that, in my original code i posted, i replaced ^ with . and it worked!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Not exactly sure what you are trying to accomplish :?

Posting your finals results allows the users to benefit as well.
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

this was my original output
SELECT
`hj`
FROM
hi DESC
i was trying to highlight FROM and DESC, but when i had ^ in my pattern, it only highlighted the first word. i wanted it to highlight FROM and DESC

so now it looks like

Code: Select all

SELECT
`hj`
FROM
hi DESC
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

what should my pattern be if i want to highlight = to green?
this is what i am putting as my pattern, replacement, and my output

Pattern : "/=/"
replacement: "<div style='color:green'> \\1 </div>"

output:
'color:green'>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

ziggy3000 wrote:what should my pattern be if i want to highlight = to green?
this is what i am putting as my pattern, replacement, and my output

Pattern : "/=/"
replacement: "<div style='color:green'> \\1 </div>"

output:
'color:green'>
You don't have to edit more than one file to get GeSHi to highlight differently. The syntax configuration is stored in one file for each language. Just edit the geshi/sql.php file. It's a big array with all the definitions and colors in it. You can change it to whatever you need. Considering GeSHi highlights declarative languages like HTML and YAML just as well as it highlights things like C, PHP and Java I would think you'll have better success with it. All you have to do is change the definitions.
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

yes i know, i already tried that. can you guys just help me with what i need, and not talk about geshi

the geshi only has arrays, not the code they used to highlight the arrays.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Geshi has more that just "arrays." The arrays only define various keywords, highlighting application rules and so forth.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

ziggy3000 wrote:yes i know, i already tried that. can you guys just help me with what i need, and not talk about geshi

the geshi only has arrays, not the code they used to highlight the arrays.
There's no \\1 in your pattern because there's no parentheses in it. Put ( and ) around the bit you want to access as \\1.
ziggy3000
Forum Contributor
Posts: 205
Joined: Fri Mar 23, 2007 3:04 pm

Post by ziggy3000 »

i am using
/(=)/
as my pattern, but it still doesn't work.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Yet again, it works for me. Make our lives easier in the future, and instead of saying "it doesn't work" post what you have tried.
Post Reply