Added resetState function#20
Added resetState function#20tzi merged 5 commits intoElephant418:masterfrom danhanly:fix-looping-indent-issue
Conversation
|
Hi @danhanly! That's a great catch! Thanks a lot 👓 It's nice of you to conceive that some situations need subsequent runs of It would be very nice of you to add a test case of the bug you fixed. Thanks again for contributing to this project! Cheers, |
|
Would you like me to take out the flag for Happy to do this - I'll write the test case today. |
|
Yes! It would be great 🍰 |
|
|
||
| $this->assertContains('>', $bqOutput); | ||
|
|
||
| $lbOutput = $converter->parseString($linebreaks); |
There was a problem hiding this comment.
👍 It's OK!
This converter produce a broken markdown on master:
Test
>
> Linebreaks
There was a problem hiding this comment.
This was the exact circumstance of the issue #19 - glad it's resolved here 👍
|
@tzi amended - travis approves 😄 |
|
It's available in the release v2.2.0. Welcome to the contributors of Markdownify! |
Issue reference: #19
The issue that I discovered is that I was using a single instance of the converter, injected into my constructor - but the actual parsing (call of
parseString) was happening within a loop.This meant that a large portion of the properties, such as indent, buffers etc were being carried over from one string to another.
>since it ends on a blockquote.>set to the indent at the beginning of its string (which is added during thehandleTag_brmethod) regardless of whether it was using a blockquote or not.There was no 'cleanup' of these properties between subsequent runs of
parseStringagainst the same instance. So here I added an optional variable toparseStringto allow you to reset it's state. I defaulted this variable to false so that we don't break backward compatibility.There are conceivable situations where you would want subsequent runs of
parseStringto inherit the properties of a previous run (a single string split into multiple parts, for instance), so I kept this in mind with this edit.