When attempting to view a node with embedded code using the <ace> tag for syntax highlighting, the page renders an empty pre tag. The weird thing, it works fine is viewing the node immediately after saving a node. If you refresh though, the pre tag is empty again.

Comments

cravecode created an issue. See original summary.

cravecode’s picture

Issue summary: View changes
cravecode’s picture

The tag is parsed in the ace_editor filter's process callback and pushed to the page as JavaScript settings. The problem is that filters that are set "cachable", skip the filter's process callback if a cache was previously set. This results in the process that generates JavaScript settings to be skipped.

I'm looking into a possible solution. I think the easiest approach is to turn off caching for this filter.

cravecode’s picture

I think I'm going to abandon this module as a syntax highlighter for published content. however, It's fantastic as an editor!

Current issues I see with this module's implementation for syntax highlighting of content:

  • Replaces <ace> tags with empty <pre> tags on server side.
  • Pushes original content to client side via JavaScript settings array.
    • This is problematic for caching and SEO

I suggest switching to use a <code> block that gets rendered to the page regardless of syntax highlighting. This is better for SEO
Then use Ace Editor to alter/style the content clientside.

If I get some free time over the next few weeks, I'll contribute a patch For now, I'll be using GeSHi

interdruper’s picture

Cravecode, thanks for reporting, I can reproduce the bug.

Changing the "pre" tag to "code" seems easy, but the problem while refreshing/caching will require more work.

Any help/patch would be appreciated.

interdruper’s picture

Ok, I have confirmed that JS cannot be added inside an input filter, because the filter caches the text and the function is never called again until the cache is next cleared. Currently the JS required from Ace is loaded inside hook_filter_FILTER_prepare(), that is the problem.

Let's find out the best way to fix this, work in progress...

  • interdruper committed fb204a7 on 7.x-1.x
    Issue #2657808 by interdruper: Embedded syntax highlighting via <ace>...
interdruper’s picture

Status: Active » Fixed

Unfortunately, by design, the only way for making this to work is disabling the filter cache for the ''Syntax highlighting' filter. If you use it, please note that since 7.x-1.8 release cache will be disabled for the content that has this filter enabled.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.