Issue #841 resolved

Bug in OpaLexer with unquoted attributes

Sanders Kleinfeld
created an issue

The following code listing is highlighted properly by the OpaLexer:

function sample_page() {
  <header>
    <h3>HTML in Opa</h3>
  </header>
  <article>
    <div class="container">
      <p>Learning by examples.</p>
    </div>
  </article>
}

But the following valid Opa syntax (with an unquoted attribute on the div) is not highlighted properly:

function sample_page() {
  <header>
    <h3>HTML in Opa</h3>
  </header>
  <article>
    <div class=container>
      <p>Learning by examples.</p>
    </div>
  </article>
}

And throws the following error:

IndexError: list index out of range
   (file "/usr/local/lib/python2.6/dist-packages/Pygments-1.5-py2.6.egg/pygments/lexer.py", line 541, in get_tokens_unprocessed)

It looks like this is an issue stemming from the OpaLexer's 'html-attr-value' section, which has no regex handling for unquoted attributes:

        'html-attr-value': [
            (r"'", String.Single, ('#pop', 'single-string')),
            (r'"', String.Single, ('#pop', 'string')),
            (r'#'+ident_re, String.Single, '#pop'),
            (r'#(?={)', String.Single, ('#pop', 'root')),
            (r'{', Operator, ('#pop', 'root')), # this is a tail call!                                                                           
        ],

Thanks, Sanders


Sanders Kleinfeld

Publishing Technology Engineer

O'Reilly Media Inc.

sanders@oreilly.com

@sandersk

Comments (3)

  1. Log in to comment