3

How can I create an autocomplete and how to highlight html, javascript and css inside php for the Ace editor http://ace.ajax.org/.

<html>
    <head>
        <title><?=$title; ?></title>
        <style>
            body {
                background: black;
                color: white;
            }
        </style>
        <script>
            alert("this is only a no-sense test script....");
        </script>
    </head>
    <body>
        This is only a no-sense test script but I want that html tags, css styles and javascript code are highlighted....<br />
        Is it possible?
    </body>
</html>

(sorry for my english)

Charles
  • 50,943
  • 13
  • 104
  • 142
  • Is this actually a feature request for the ace editor? Apart from that, highlighting code within php code is supposedly something wickedly difficult. I use Aptana, which I think is a very fine and enhanced IDE, but even that doesn't highlight html code in say an echo php-statement... – kasimir Oct 29 '11 at 13:01
  • i do not want to highlight code inside strings.... – Seingh Haccoski Oct 29 '11 at 14:25

3 Answers3

2

As of a few months ago the Ace Editor now supports autocomplete (see: http://ace.c9.io/#nav=about)

vbguyny
  • 1,170
  • 1
  • 10
  • 29
2

These are two questions.

  1. How can I create an autocompleter that completes PHP?

  2. How can I syntax highlight HTLM code inside PHP code?

For the second question, there is some discussion in the Google group for Ace Editor In my opinion, the question is not really answered if it is possible or not, but it seems at least doable. Have a look at the documentation for highlighter, especially about the part "Embedding a different highlighter".

For autocompletion, I don't see a chance at all. See the Google group entry about a similar (recent) question.

mliebelt
  • 15,345
  • 7
  • 55
  • 92
0

For any one still looking around for this, I found exactly what I needed here: https://github.com/ajaxorg/ace/wiki/How-to-enable-Autocomplete-in-the-Ace-editor

I wanted to enable live auto-completion, so there is another option enableLiveAutocompletion and enableSnippets (to give a brief description of the suggestion if available).

I used it like this:

editor.setOptions({
     enableLiveAutocompletion: true,
     enableSnippets: true
 });

There is also an example demonstrating how you could add a custom completer to return results tailored to your specific project.

segFault
  • 3,887
  • 1
  • 19
  • 31