ajaxorg / ace

Ace (Ajax.org Cloud9 Editor)
https://ace.c9.io
Other
26.54k stars 5.27k forks source link

PHP syntax highlight not working with local source #1142

Closed Piedone closed 11 years ago

Piedone commented 11 years ago

When I use the latest source of Ace (I tried all four: standard, min, noconflict, noconflict min) from under a local path PHP syntax highlighting is gone. PHP mode loads, with breakpoints I see that it also runs but PHP editing is messed up (also indenting breaks e.g.). No problem with JS or C#. Using the CDN source (//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js) it works, however that has other issues: http://stackoverflow.com/questions/13369972/ace-editor-javascript-flavor-failed-to-load-script-exception

nightwing commented 11 years ago

from under a local path

do you mean with something like file://foo/bar/editor.html? if yes take a look at https://github.com/ajaxorg/ace/wiki/Running-Ace-from-a-file: browsers usually restrict access to file protocol for security reasons and one needs to change configuration or use local server.

Piedone commented 11 years ago

Thanks, for the quick reply, but no. I'm running a a web site locally on a local web server. So more precisely the Ace files are under a local url - local to the website's root. And also there's no problem with file access, as mentioned the PHP mode script runs as breakpoints in it are hit, but only highlighting is messed up.

nightwing commented 11 years ago

That's strange, there aren't many ways it can fail after script is loaded. Could you give a url to the website (or some other example page) to reproduce this issue?

Piedone commented 11 years ago

Thanks for the continued help. I'll set up a test site for this shortly.

Piedone commented 11 years ago

It's up. It's an Orchard CMS site with a scripting engine supporting among other PHP scripting. You can open the scripting testbed at http://orchardscripts.cloudapp.net/Admin/OrchardHUN.Scripting/Testbed Log in with admin/password. On the testbed you can run e.g. PHP scripts. As you can see when selecting JS or C# syntax highlighting works (under the Help collapsed box you can look at examples) but no highlighting for PHP.

nightwing commented 11 years ago

ah i see, you probably want to highlight pure php, and ace php mode is for php embedded in html

<?php
$ew = function(){
} 
?>

is highlighted fine

Piedone commented 11 years ago

I see, thank you. Indeed this was the case. Any option of not having to use the PHP tags? "Pure" PHP is just working with the CDN version of Ace, so I guess the build on Github is a more recent version where this behaviour changed.

nightwing commented 11 years ago

old implementation was highlighting a<b as a tag everywhere. Would it be enough to add an option to assume <? and not highlight any tags, or you need autodetection based on content?

Piedone commented 11 years ago

Thanks for the continuous support. Some option to assume the surrounding php tags and thus the ability to use "pure" PHP would be great.

nightwing commented 11 years ago

see https://github.com/ajaxorg/ace/commit/7cf188e07f1b32cec5d00b5092d55f1a62841cff, with that one needs to do

var Mode = require("ace/mode/php").Mode
var m=new Mode({pure: true}) // need to think of better name for this option!
editor.session.setMode(m)

which isn't very convenient. I see two ways to improve this

editor.session.setMode("ace/mode/php!pure")
editor.session.setMode({path: "ace/mode/php", pure:true, /*other options here*/})

probably second one is better, what do you think?

Piedone commented 11 years ago

Thank you very much for the patch! I've taken a look at the changeset. Yes, probably the last one looks the best, especially if there are or can be other options (I think that's not the case BTW at the moment, right?). Also it's consistent with the way how most of the JS libraries handle settings. How about "inline" for the option name?

Piedone commented 11 years ago

Wow, so you've created an implementation?

nightwing commented 11 years ago

Yes with that session.setMode({path:"ace/mode/php", inline:true}) will highlight php without <?php ... ?>. Is that ok? (btw, thanks for the idea with 'inline' name)

Piedone commented 11 years ago

That's great, thank you very much! When is the next release due? :-) BTW thanks again for the great support! That's the kind of open-source support I also strive to provide the users of my open source software.

nightwing commented 11 years ago

This is merged now, and ace-builds repository will be updated next week. Thanks for using ace, and reporting bugs!

Piedone commented 11 years ago

Thank you, awesome!

pumpi commented 10 years ago

the inline true is highlight the code but dont valid him. i dont geht an Sysntax error or something on the gutter.