[code] [textadept] bug with markdown syntax highlighting

From: Heck Fy <shitpoet.att.gmail.com>
Date: Mon, 10 Aug 2015 09:13:29 +0300

Hello!

Steps to reproduce the bug:

0. start `textadept` or `textadeptjit` 8.1 x64 stable or nighty build
from console:

    textadept -u /tmp/testa

1. create new file and select markdown lexer (or open existing md file
or create new one and save it with md extension)
1. write "_" symbol
2. notice erors in console:

Lua Error: .../textadept_NIGHTLY_2015-08-09.x86_64/lexers/markdown.lua:36:
attempt to index a nil value (local 'line').
Lua Error: Table of tokens expected from 'lexer.lex'.
Lua Error: .../textadept_NIGHTLY_2015-08-09.x86_64/lexers/markdown.lua:36:
attempt to index a nil value (local 'line').
Lua Error: Table of tokens expected from 'lexer.lex'.
Lua Error: .../textadept_NIGHTLY_2015-08-09.x86_64/lexers/markdown.lua:36:
attempt to index a nil value (local 'line').
Lua Error: Table of tokens expected from 'lexer.lex'.
Lua Error: .../textadept_NIGHTLY_2015-08-09.x86_64/lexers/markdown.lua:36:
attempt to index a nil value (local 'line').

and so on. TA doesnt hang nor crash, all is ok, just syntax
highlighting is wrong.

I noticed the problem when was writing a link address with '_' symbol
and then write some identifier containing '_' symbol. Unfortunately
the '_' there and there arent rare. So the highlighting is corrupted
for me frequently.

I've found that surrounding word with '_' makes it italic in markdown.
( link to docs about em in markdown:
http://markdown-guide.readthedocs.org/en/latest/basics.html#emphasis-italics
)

If i translate test md file

    # Markdown test

    _left

    _right_

    _both_

using markdown 1.0.1

    $ markdown -v

    This is Markdown, version 1.0.1.
    Copyright 2004 John Gruber
    http://daringfireball.net/projects/markdown/

    $ markdown test.md
    <h1>Markdown test</h1>

    <p>_left</p>

    <p>right_</p>

    <p><em>both</em></p>

Markdown makes italic words that are surrounded by '_' only. But
several versions of textadept (7.9 stable, 8.1 stable, 8.1 night) that
i tested on my x64 Linux system italize everything after '_'.

i've read code in lexers/markdown.lua and i think that the problem may be here:

--lexers/markdown.lua:59

local em = token('em',
                 l.delimited_range('*', true) + l.delimited_range('_', true))

May be we need to check that starting '_' symbol has whitespace before
and ending '_' symbol has ws after it? or what?.. For now i just
commented this 'em' token out.

May be there's something with 'hr' token because TA reported errors in it?

p.s. I dont have another OS to test so may be there's something
special for my OS setup.

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Mon 10 Aug 2015 - 02:13:29 EDT

This archive was generated by hypermail 2.2.0 : Mon 10 Aug 2015 - 06:30:52 EDT