Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2004, 04:26 PM
trican trican is offline
 
Join Date: Aug 2004
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default custom vb BB codes

Hi,

I'd like to setup BB code for a programming language in a similar fashion to the way its done for php (e.g.
PHP Code:
code 
. Could anyone point me in the right direction!

Also I've seen some sites which do syntax highlighting of code is this hard?

thanks
Reply With Quote
  #2  
Old 09-02-2004, 06:41 PM
trican trican is offline
 
Join Date: Aug 2004
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

no -one?
Reply With Quote
  #3  
Old 09-03-2004, 10:08 AM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would have to find a PHP script that does the syntax highlighting for the language in question. That's the hard part. Once you have that, hanging it off of a bbcode is the simple part.
Reply With Quote
  #4  
Old 09-03-2004, 10:25 AM
trican trican is offline
 
Join Date: Aug 2004
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

would that not be fairly straight forward, just send the post to function, which parses it looking for keywords, and then replacing the keyword with A BBCODE for different colours?

You think it would be easy to "hang it off" vb?
Reply With Quote
  #5  
Old 09-03-2004, 11:30 AM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by trican
would that not be fairly straight forward, just send the post to function, which parses it looking for keywords, and then replacing the keyword with A BBCODE for different colours?

You think it would be easy to "hang it off" vb?
Writing a language parser is non-trivial. I have written a couple from scratch and, more frequently, used lexical/parser tools to define a language parser to do the job.

It is not as simple as looking for keywords. If you did that, you would incorrectly highlight keywords within strings, as in:

$variable = "foreach $string } ?> ";

You must be able to break the input into a syntactically correct stream of tokens, then parse the tokens into a semantically correct series of language constructs, such as statements and expressions.
Reply With Quote
  #6  
Old 09-03-2004, 11:41 AM
trican trican is offline
 
Join Date: Aug 2004
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CarCdr
Writing a language parser is non-trivial. I have written a couple from scratch and, more frequently, used lexical/parser tools to define a language parser to do the job.

It is not as simple as looking for keywords. If you did that, you would incorrectly highlight keywords within strings, as in:
And checking if there was a space bewfre and after wont be enough?

Quote:
]
You must be able to break the input into a syntactically correct stream of tokens, then parse the tokens into a semantically correct series of language constructs, such as statements and expressions.
I'm not really too sure I understand what you mean by stream of token, etc



Ultimately i dont see why it wouldn't be as easy as copying the current VB php pharser and modifying the keyword, so as to suit the chosen language?

If i were to pay for a hack like this, how much would it cost do you think?
Reply With Quote
  #7  
Old 09-03-2004, 01:18 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is nothing you can copy and modify. There is no "VB php parser". It uses the highlight_string function that comes as part of PHP.

This is not as easy as you think. Any simple methods are doomed to produce silly results.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:30 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04205 seconds
  • Memory Usage 2,216KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete