User login

Drupal.org's PHP input format

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
/* The <?php and
?>

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
*/
?>

Resolution

Comments

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.
  */
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.