Skip to content

Commit

Permalink
Further fixes Coconut syntax highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Feb 12, 2016
1 parent 4474cda commit 406b70b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def factorial(n):
```

Copy, paste! This definition differs from the recursive definition only by one line. That's intentional: because both the iterative and recursive approaches are functional approaches, Coconut can provide a great assist in making the code cleaner and more readable. The one line that differs is this one:
```python
```coconut
return range(1, n+1) |> reduce$((*))
```

Expand Down
16 changes: 10 additions & 6 deletions coconut/highlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@

class pylexer(Python3Lexer):
"""Lenient Python syntax highlighter."""
name = "force_python"
name = "Force Python"
aliases = ["force_python", "force_py", "force_python3", "force_py3"]
filenames = []

def __init__(self, stripnl=False, stripall=False, ensurenl=True, tabsize=tablen, encoding=encoding):
"""Initialize the Python syntax highlighter."""
super(pylexer, self).__init__(stripnl=stripnl, stripall=stripall, ensurenl=ensurenl, tabsize=tabsize, encoding=encoding)
def add_filter(self, *args, **kwargs):
"""Disables the raiseonerror filter."""
print(args, kwargs)
if len(args) >= 1 and args[0] != "raiseonerror":
super(pylexer, self).add_filter(*args, **kwargs)

class pyconlexer(PythonConsoleLexer):
"""Lenient Python console syntax highlighter."""
name = "force_pycon"
name = "Force Python Console"
aliases = ["force_pycon", "force_pycon3"]
filenames = []

def __init__(self, stripnl=False, stripall=False, ensurenl=True, tabsize=tablen, encoding=encoding, python3=True):
"""Initialize the Python console syntax highlighter."""
super(pyconlexer, self).__init__(stripnl=stripnl, stripall=stripall, ensurenl=ensurenl, tabsize=tabsize, encoding=encoding, python3=python3)
def add_filter(self, *args, **kwargs):
"""Disables the raiseonerror filter."""
print(args, kwargs)
if len(args) >= 1 and args[0] != "raiseonerror":
super(pyconlexer, self).add_filter(*args, **kwargs)

class coclexer(pylexer):
class coclexer(Python3Lexer):
"""Coconut syntax highlighter."""
name = "coconut"
name = "Coconut"
aliases = ["coc", "coconut", "force_coc" "force_coconut", "coconutcon", "force_coconutcon"]
filenames = ["*"+code_ext]

Expand All @@ -66,3 +66,7 @@ class coclexer(pylexer):
]
tokens["backtick"] = [("`.*?`", String.Backtick)]
tokens["name"] = tokens["name"] + [(r"[$\\]", Operator)]

def __init__(self, stripnl=False, stripall=False, ensurenl=True, tabsize=tablen, encoding=encoding):
"""Initialize the Python syntax highlighter."""
super(coclexer, self).__init__(stripnl=stripnl, stripall=stripall, ensurenl=ensurenl, tabsize=tabsize, encoding=encoding)

0 comments on commit 406b70b

Please sign in to comment.