#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)
Change History (11)
comment:1 by , 18 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:2 by , 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 , 18 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
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 , 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.
follow-up: 10 comment:5 by , 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 , 17 years ago
Attachment: | screenshot_trac.png added |
---|
Finally able to upload the abovementioned screenshot
comment:6 by , 17 years ago
Milestone: | → 0.12 |
---|---|
Severity: | normal → minor |
comment:7 by , 16 years ago
Keywords: | pygments added |
---|
comment:8 by , 15 years ago
Milestone: | next-major-0.1X → unscheduled |
---|
comment:9 by , 10 years ago
Owner: | removed |
---|---|
Status: | reopened → new |
comment:10 by , 10 years ago
Milestone: | unscheduled |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
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.
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.