Titor8115 / mandown

man-page inspired Markdown viewer
GNU General Public License v3.0
246 stars 13 forks source link

Multiple Parser errors (Ignore parsing certain elements) #5

Closed HackingPheasant closed 4 years ago

HackingPheasant commented 4 years ago

I saw this tool from the reddit post. So I downloaded and gave it a go on my blogs markdown files, which didn't go so well.

How I installed

git clone https://github.com/Titor8115/mandown.git
cd mandown
make
sudo install -C -m 755 -o root -g root mandown /usr/bin/mdn

Gave it a test run on the readme from the repo and it seemed to work. I then next went to my blog post. This one specifically which follows GitHub Flavored Markdown Spec

Errors

noname.xml:9: parser error : Opening and ending tag mismatch: br line 8 and p
79/">reference</a>. With this short preamble out of the way lets get into it!</p
                                                                               ^
noname.xml:11: parser error : Opening and ending tag mismatch: br line 11 and p
r to me, as they all had different cons and gotchas, with very few pros.<br> </p
                                                                               ^
noname.xml:13: parser error : Opening and ending tag mismatch: use line 13 and code
/SVG/Element/use#Browser_compatibility">compatibility</a> for <code><use></code>
                                                                               ^
noname.xml:13: parser error : Opening and ending tag mismatch: code line 13 and p
ser_compatibility">compatibility</a> for <code><use></code> is  pretty good. </p
                                                                               ^
noname.xml:41: parser error : Opening and ending tag mismatch: symbol line 41 and code
se></code> - <strong>Does work</strong> (this requires the <code><symbol></code>
                                                                               ^
noname.xml:41: parser error : Opening and ending tag mismatch: use line 41 and code
n.svg to have an id attached to it so you can reference it in <code><use></code>
                                                                               ^
noname.xml:41: parser error : Opening and ending tag mismatch: code line 41 and p
g to have an id attached to it so you can reference it in <code><use></code>)</p
                                                                               ^
noname.xml:90: parser error : Opening and ending tag mismatch: code line 41 and article
</article>
          ^
noname.xml:91: parser error : Premature end of data in tag br line 40

^
noname.xml:91: parser error : Premature end of data in tag br line 40

^
noname.xml:91: parser error : Premature end of data in tag p line 39

^
noname.xml:91: parser error : Premature end of data in tag p line 13

^
noname.xml:91: parser error : Premature end of data in tag p line 11

^
noname.xml:91: parser error : Premature end of data in tag p line 8

^
noname.xml:91: parser error : Premature end of data in tag hr line 2

^
noname.xml:91: parser error : Premature end of data in tag article line 1

^
error: Failed to parse document

Side note

man-page inspired Markdown viewer This tool is fine to be used as a general purpose markdown viewer correct, or did I misinterpret the tagline?

Titor8115 commented 4 years ago

That’s not the issue on your side. It’s just that the project isn’t finished yet and I haven’t finished figuring out all the rendering rules for every node tags.

I’ll add XML_PARSE_RECOVER option in the source code to see what would happen.

Would you mind sharing the parts of your document that causes the error? So that I could figuring out the rendering rules for it

HackingPheasant commented 4 years ago

Document was shared in original post, but it seems to break on lines like this Its hard to point to the exact lines as the line numbers referenced in the error message don't match to the line numbers in the document (and some of the error messages don't give enough context to manually locate it)

Titor8115 commented 4 years ago

Document was shared in original post, but it seems to break on lines like this Its hard to point to the exact lines as the line numbers referenced in the error message don't match to the line numbers in the document (and some of the error messages don't give enough context to manually locate it)

Thanks for the feedback and the source. I’ll try to patch it soon

Titor8115 commented 4 years ago

Document was shared in original post, but it seems to break on lines like this Its hard to point to the exact lines as the line numbers referenced in the error message don't match to the line numbers in the document (and some of the error messages don't give enough context to manually locate it)

The parsing issue should be fixed by the new patch. I run tests on the document you posted. And turns out its the empty elements, such as <br>, that cause the issue.

However, there is another issue. For some reason libxml2 parser decided to eat all html tag/content if it is in <code> block. But it seems that non-valid html tag such as <use> won't be affected by this. I'm not an expert about libxml2. But I'll try to figure it out soon. By if you know anything about this part, more feedback would be awesome