mdast_util_to_markdown panics while trying to format UTF text with trailing spaces
Hi there,
There is a bug somewhere in state.rs → container_phrasing(), which makes it panic with the message like "byte index 212 is not a char boundary" at line 245. I reproduced it in simple test: https://github.com/johnlepikhin/markdown-rs/commit/e4c451ad85a1a3348ea094bfa6dd10d0a4e12178. Please note that source markdown at lines 7-9 contains sequence:
<UTF-8 character> <SPACE> <SPACE> <NEWLINE>
Found another case which reproduces probably the same issue: https://github.com/johnlepikhin/markdown-rs/commit/3614cbefddb6e366724a02fcc7b1f9f2c60ce048. The first character in markdown document is UTF-8.
The former might be variation on https://github.com/wooorm/markdown-rs/pull/31 The latter looks like a variant of https://github.com/wooorm/markdown-rs/pull/22
I was able to reproduce the issue using the second test case you provided and I fixed it in here #170
Can you check if you can reproduce the panic that's happening in the first test case using the fix provided in the PR ?
Thank you, @bnchi! Both cases were fixed.