MatlabLexer cannot handle literal "function*" occurences

Issue #1491 new
Former user created an issue

If the Matlab code contains a variable named function.* word anywhere which is not an actual function header, then it will be misinterpreted for example:

classdef ClassExample
    % function in the comment
    % _function_ in the comment
    % function_ in the comment

        function functionInTheName(obj)
            variable_function = 10;
            functionVariable = 10;

This causes a problem in the sphinxcontrib-matlab python package

Comments (1)

  1. Gergely Gulyas

    (Original poster) Found the problem, The keyword token does not checks for the following character:

    (r'^\s*function', Keyword, 'deffunc'),

    which can be only a space or a square bracket so:

    (r'^\s*function(?=[\s[])', Keyword, 'deffunc'),

    seems to work.

  2. Log in to comment