Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headers broken after newline and EOF #45

Open
NCarson opened this issue Feb 5, 2020 · 1 comment
Open

headers broken after newline and EOF #45

NCarson opened this issue Feb 5, 2020 · 1 comment

Comments

@NCarson
Copy link

NCarson commented Feb 5, 2020

Given two commands, the first ending in newline and the second with more text; only the the second will print a header.

$ echo '#h1
' | ./mdless -P ; echo '#h1
hello' | ./mdless -P

gives (extra blank lines removed):

#h1 

h1 ======================================================================================================================
hello

I do not know if this intentional but in my mind markdown tags stand alone without context. And Github seems to agree with me (see very last line showing same idea).

In any case when this line https://github.com/ttscoff/mdless/blob/develop/lib/mdless/converter.rb#L190:

headers = input.scan(/^((?!#!)(\#{1,6})\s*([^#]+?)(?: #+)?\s*|(\S.+)\n([=-]+))$/i)

is changed to:

headers = input.scan(/^((?!#!)(\#{1,6})\s*([^#]+?)(?: #+)?[ \t]*|(\S.+)\n([=-]+))$/i)

(last \s changed to [ ^t]) fixes my test case.

Although I dont know if that causes any other repercussions.

Github rendering of # test\nEOF:

test

@NCarson NCarson changed the title headers broken on \nEOF inline Feb 5, 2020
@NCarson NCarson changed the title inline headers broken after newline and EOF Feb 5, 2020
@ttscoff
Copy link
Owner

ttscoff commented Feb 6, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants