ttscoff/mdless

Crash when using shebang inside code block

VeteraNovis opened this issue · 4 comments

Description of Error

If a code block contains a shebang (#!) at the start of the line (or preceeded by whitespace characters), then mdless will crash with the following error:

Traceback (most recent call last):
	9: from /snap/mdless/274/bin/mdless:23:in `<main>'
	8: from /snap/mdless/274/bin/mdless:23:in `load'
	7: from /snap/mdless/274/gems/mdless-1.0.21/bin/mdless:17:in `<top (required)>'
	6: from /snap/mdless/274/gems/mdless-1.0.21/bin/mdless:17:in `new'
	5: from /snap/mdless/274/gems/mdless-1.0.21/lib/mdless/converter.rb:127:in `initialize'
	4: from /snap/mdless/274/gems/mdless-1.0.21/lib/mdless/converter.rb:127:in `each'
	3: from /snap/mdless/274/gems/mdless-1.0.21/lib/mdless/converter.rb:140:in `block in initialize'
	2: from /snap/mdless/274/gems/mdless-1.0.21/lib/mdless/converter.rb:586:in `convert_markdown'
	1: from /snap/mdless/274/gems/mdless-1.0.21/lib/mdless/converter.rb:586:in `gsub!'
/snap/mdless/274/gems/mdless-1.0.21/lib/mdless/converter.rb:600:in `block in convert_markdown': undefined method `[]' for nil:NilClass (NoMethodError)

Sample file

Attached is an example file which crashes upon attempting to be read
mdless-crash.md

Version

mdless 1.0.21

system

Ubuntu 21.04

Ah it was happening even with content. I only stripped it down to the shebang to keep it as simple as possible when testing the crash.

I first noticed it with code block like the following

#!com.test.sample

Thanks for the work mate!