Wrong highlighting in of Smarty sourcecode #956

Develooper opened this Issue Nov 12, 2012 · 10 comments


None yet
3 participants

Smarty source code isn't highlighted correctly.
{$result = {math equation="x + y" x=5 y=10}}

The opening brace of the math-function and the function name itself are shown in blue, like attributes, but they should be shown in green.
Additionally, the second closing brace is displayed in black, but should be green as well.

Without assignment, the highlighting is correct:
{math equation="x + y" x=5 y=10}


marijnh commented Nov 12, 2012

@benkeen care to take a look?


benkeen commented Nov 12, 2012

Sure! My time's not great these days, but I'll see if I can figure something out.

  • Ben

benkeen commented Nov 14, 2012

Hi Develooper,

I'm afraid the Smarty mode actually only supports Smarty 2, not 3. Smarty 3 contains a number of new short-cuts and syntactical changes over Smarty 2, such as the problem you posted.

When I get a little more time I'll investigate all the changes that have been made and update the Codemirror mode.

Sorry about that!

  • Ben

@marijnh marijnh closed this May 20, 2013

Why was this issue closed? It's still not fixed.


marijnh commented May 21, 2013

Apparently @benkeen is aware of the problem. I myself am not going to work on this. Fixes are welcome, but I'm trying to keep the issue list focused on things that concern me.

In that case it would make sense if you write on codemirror.net at "Supported modes", that it only support Smarty 2 syntax. Currently it looks like CodeMirror would support all Smarty versions (including Smarty 3-syntax).


benkeen commented May 21, 2013

Hi Develooper - I'll take a look at this and see if I can add in support for Smarty 3. Keep you posted!

  • Ben

benkeen commented May 22, 2013

Hi Develooper. I updated the mode tonight to allow for the new Smarty 3 syntax. Pending pull request, but you can see it here: http://www.benjaminkeen.com/experiments/CodeMirror/mode/smarty/

All the best!

  • Ben

Hello Ben,

thank you, that's wonderful!

I've just found a problem with Smarty comments. May I post them here?

{$a = 1} {* set $a to "1 }
{$b = 2} {
set $b to "2 }
{$c = 3} {
set $c to "3 }
{$d = 4} {
set $d to "4 }
{$e = 5} {
set $e to "5 }
{$f = 6} {
set $f to "6 }
{$g = 7} {
set $g to "7 *}

{* ##### Example Code ##### *}

If you copy it into your Smarty3-box it looks very colorful, but it shouldn't. It seems like the content of comments get parsed like normal code.

It seems like the comment editor on github is buggy too. it removes the * at the beginning and end of the Smarty comment. Only the first opening comment is shown corrently here.


benkeen commented May 22, 2013

Hey, Develooper. Ah! Glad you caught this. I'll check it out tomorrow night. Thanks :)

EDIT: Huh... actually, isn't this correct? If the comment isn't properly closed, it will all appear as a comment until the closing *}. Feel free to email me it if github's mutilating the code. (ben.keen@gmail.com)

  • Ben
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment