Edgewall Software
Modify

Opened 19 years ago

Closed 9 years ago

Last modified 9 years ago

#1932 closed defect (duplicate)

WikiFormatting does not detect php files

Reported by: Chris Petersen <xris*siliconmechanics.com> Owned by:
Priority: normal Milestone:
Component: wiki system Version: devel
Severity: minor Keywords: pygments
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I've tried <?php and #!php inside of {{{ }}} but neither enables php syntax highlighting.

Attachments (1)

screenshot_trac.png (32.2 KB ) - added by kontakt at meitzner dot net 17 years ago.
Finally able to upload the abovementioned screenshot

Download all attachments as: .zip

Change History (11)

comment:1 by Matthew Good, 18 years ago

Resolution: worksforme
Status: newclosed

Trac doesn't infer the language from content like "<?php". However, the #!php line does work. If it's not colored you either need to install SilverCity, Enscript, or set the "php_path" setting in trac.ini.

comment:2 by Tim Hatch <trac@…>, 18 years ago

Also note that using the shebang #!php only works on the first line of a multiline code block. It doesn't work inline.

You'd use it like this — but see WikiProcessors for more examples.

 {{{
 #!php
 function x() {}
 }}}

comment:3 by kontakt at meitzner dot net, 18 years ago

Resolution: worksforme
Status: closedreopened

Well, I've just made the experience that the abovementioned does not work as expected for me either.

Adding PHP-Sourcecode just with the shebang notation results merely in the code block background set to white instead of grey.

Only when I add additional <?php and ?> Tags at the beginning and end of the code block, the syntax highlighting is done. See Examples above, which show the behavior as of 2007-04-19. Now, I could not read from the documentation or this ticket that this behavior was intended. I regard it a bug, since the additional Tags are IMHO not "correct" on code excerpts.

// Comment
if ('1' != $is_it_true) {
  die('It\'s not true!');
}
<?php
// Comment
if ('1' != $is_it_true) {
  die('It\'s not true!');
}
?>

However, since this behavior may change with time in this online-version of trac, I'll add an additional screenshot in a minute.


Trac:0.11dev
Python:2.5 (release25-maint, Feb 16 2007, 18:42:37) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu1)]
SQLite:3.3.10
pysqlite:2.3.2
Genshi:0.4dev-r494
Pygments:0.6
Subversion:1.4.2

comment:4 by kontakt at meitzner dot net, 18 years ago

Hmm, I've got this nifty little screenshot, but I can't upload it due to unresolved #4087… Let me know if I should submit it otherwise.

comment:5 by Matthew Good, 18 years ago

Changing #!php to highlight as PHP snippets would break the consistency of how this is handled as well as making it impossible for people to include sections that mixed HTML and PHP sections in the Wiki. The Pygments PHP lexer does provide an option for "inline" PHP code without the <?php starting, so it would be possible to implement a plugin providing this type of highlighting under another name. I'm not sure if this belongs in the core, but I'll leave this open for now.

by kontakt at meitzner dot net, 17 years ago

Attachment: screenshot_trac.png added

Finally able to upload the abovementioned screenshot

comment:6 by Piotr Kuczynski <piotr.kuczynski@…>, 16 years ago

Milestone: 0.12
Severity: normalminor

comment:7 by Piotr Kuczynski <piotr.kuczynski@…>, 16 years ago

Keywords: pygments added

comment:8 by Remy Blank, 14 years ago

Milestone: next-major-0.1Xunscheduled

comment:9 by Ryan J Ollos, 10 years ago

Owner: Jonas Borgström removed
Status: reopenednew

in reply to:  5 comment:10 by Ryan J Ollos, 9 years ago

Milestone: unscheduled
Resolution: duplicate
Status: newclosed

Replying to mgood:

Changing #!php to highlight as PHP snippets would break the consistency of how this is handled as well as making it impossible for people to include sections that mixed HTML and PHP sections in the Wiki.

I'm unsure how to relate this comment to the current behavior in Trac, but perhaps it applies to one of the older syntax highlighting packages (SilverCity, Enscript) or PhpRenderer. Support for those was removed in [13199].

Pygments is the only supported syntax highlighter in Trac 1.1.4 and later, and it has both PhpLexer and PhpHtmlLexer.

The Pygments PHP lexer does provide an option for "inline" PHP code without the <?php starting,

I've tested and the startsinline option works. #5654 will allow php.startsinline to be specified in trac.ini, thereby customizing the behavior of PhpLexer to a particular Trac instance. Closing as a duplicate of #5654.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.