Drupal.org's PHP input format

By Benjamin Melançon
on 25 Dec
1 comment

Description

how does Drupal.org do its PHP input filter?

the one that if you put PHP tags around it it will make nicely formatted and colored code

(may have posted this question on agaric)

Thanks Lullabot!

http://www.lullabot.com/articles/drupal_input_formats_and_filters

Code Filter Renders syntax-highlighted PHP code. This module is used on Drupal.org.

http://drupal.org/project/codefilter

See more input filters in the Filters and Editors category:
http://drupal.org/project/Modules/category/63

An example of the codefilter input format making PHP all pretty:

<?php
 
print "Oh joy it works!";
?>

And for Dan, a test to see if it will do the in-page horizontal scrollbar so that it will not break the formatting of these carefully crafted pages:

<?php
  drupal_set_message
("Just put php tags of the real kind around your code, and after enabling the codefilter module, and adding the Code filter on your desired input formats (Filtered HTML and Full HTML recommended, enabling it on real PHP input decidedly not recommended!), you'll be able to make silly text like this!");
// a reminder though, you should mention to your readers
tags are for the purpose of the example only
and in their real code, they may already be in PHP code, or for most Drupal
modules, only the beginning php tag is used
*/
?>

 

Note that the above

Note that the above demonstrates that a) the code filter appears to choose to wrap code rather than causing a horizontal bar, and b) putting >?php tags *in* the format-initiating php tags used messes things up, apparently destroying an entire line above.

<?php
 
/* That line
     was part of
     a multiline comment
     which evidently works.
  */
?>

Posted by Benjamin Melançon on Tue, 2007-12-25 21:50
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.