ttscoff/mdless

Headlines with parentheses, question marks not parsed as headlines

ernstki opened this issue · 2 comments

Headlines that contain certain characters (which look like they could be regex metacharacters) do not get parsed as headlines. I haven't done an exhaustive search, but I've noticed that parentheses and question marks are among the characters that cause this.

I'm using version 1.0.9 freshly installed with gem install on macOS Mojave (10.14), with the built-in Ruby 2.3.7something.

Given this input, I expect all three headlines to be parsed correctly:

mdless <(echo "# A header (with parentheses)

Words.

## a subheader - with a question mark?

Words, words.

## a subheader with no funny stuff

Words, words, words.")

…but only the third headline "a subheader with no funny stuff" actually is. The output looks like this:

test_with_funny_chars_thumb

If you remove the offending characters (parentheses and question marks in this example), you get the expected output:

test_no_funny_chars_thumb

I'm no whiz at the git bisecting, but I'm pretty sure this behavior didn't exist a year or so ago, when I was using mdless to run terminal-based "slideshows" for a workshop.

@ttscoff I'm happy to do a PR (and even include tests that catch the above bad behavior) if you can give me a gentle push in the right direction.

Since I'm not a real Ruby developer, my efforts to look into the situation after git cloneing the repository were somewhat frustrated when bundle exec rake just gave me a backtrace (#43).