Would it be easy to get support for php syntax highlighting?
Can the module work with codefilter module?

Here are two examples from the date.module.

In this advanced help page, the code highlighting is hard coded into the html:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/date/help/d...

In this one, a full block of php code is placed within <pre> tags, without any highlighting. Using <code> tags do not work:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/date/help/f...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

beginner’s picture

The advanced help output can be altered:

drupal_alter('advanced_help_topic', $output, $popup);

So if the maintainer won't implement it, at least we can create a little module which would filter the output with codefilter for automatic syntax highlighting. I haven't tried yet, but it looks fairly easy after all.

merlinofchaos’s picture

I would really like code filter output, myself, but I was leery of doing it since it is an external module and we obviously don't want a dependency on it.

That said, I think maybe a setting that turns on codefilter filtering IF codefilter module is enabled is a good idea. That won't fly in core, probably, the codefilter could use drupal_alter for that version. For contrib, though, I'm willing to make codefilter not do the dirty work unless the maintainer wants to do it.

Patches considered.

beginner’s picture

There is the additional problem that codefilter uses the <code> tags.
The php block in the example above uses <pre> tags.

<code> tags without codefilter just won't do.
<pre> tags with codefilter won't do either.

Hmmm... I guess the module would have to use both sets of tags, so that it works both with and without codefilter.

merlinofchaos’s picture

In theory we could apply .css to the code tag so that it works properly. I didn't try very hard to do it, though.

beginner’s picture

FileSize
788 bytes

I tested a bit using the date.module (?q=help/date_api/form-elements) and the attached patch.

It doesn't work without patching date.module because the html contains &lt;?php ... ?&gt; and not <?php ... ?>.
If I patch date.module so that it has the proper php tags, codefilter works, but then without it the page is unreadable!

beginner’s picture

Status: Active » Needs work
FileSize
1.02 KB

This patch is a bit of a hack, but it works without patching date.module.

Since the help pages are supposed to be only html, it should be ok to check for php code this way and replace the html tags into real php tags to be filtered.

beginner’s picture

I noticed Karen of this thread:
#343072: syntax highlighting for advanced help.

helior’s picture

#1649588: Support Input Filters might also interest you for achieving syntax highlighting via input filters. If this approach makes more sense for the feature request on this issue, please mark this issue as a duplicate.

gisle’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)
Related issues: +#1405734: Output READMEs as parsed Markdown

I don't want to create an dependency on Codefilter. Having it optional will mean that people who don't have Codefilter installed will see nothing (or garbage) instead of markup on advanced help-pages. This is not desired behaviour.

I plan to implement filtering by Markdown as an option for README.md (see #1405734: Output READMEs as parsed Markdown). This will allow the use of backquotes, indentation to mark inline code and code blocks. Markdown is designed to degrade nicely for people who don't have Markdown installed.