bobheadxi / readable

👓 Opinionated Markdown formatter, featuring semantic line breaks
https://bobheadxi.dev/semantic-line-breaks/
20 stars 4 forks source link

Formats in the middle of sentence when faces `e.g.` #17

Closed m-spitfire closed 1 year ago

m-spitfire commented 1 year ago

TSIA.

To reproduce (file named hir.md):

For example, the contents of individual items (e.g. modules, functions, traits, impls, etc) in the HIR are not immediately accessible in the parents.

run

readable fmt hir.md

Result:

For example, the contents of individual items (e.g.
modules, functions, traits, impls, etc) in the HIR are not immediately accessible in the parents.

Expected result: File not to change.

Issue occurs in master commit https://github.com/bobheadxi/readable/commit/8e53ead732ac73e4d6e0d29ebca407083525b0be and v2.2 release.

bobheadxi commented 1 year ago

Hey @m-spitfire - thanks for reporting this, it is a similar issue to one I ran into in https://github.com/bobheadxi/readable/issues/7#issuecomment-765043636. I while back I dug into trying to fix it (~#13~ looks like I never pushed any actual code), and I found the model readable was originally based on is not great - and I think the tool as a whole needs a completely different paradigm internally. I even took a stab at writing a grammar but it didn't work out too well 🙃

I think readable might be overthinking the problem a bit - looking at the implementation in https://github.com/rust-lang/rustc-dev-guide/pull/1485 it is much simpler, and it might provide sufficient line-breaking without doing silly things like readable does

bobheadxi commented 1 year ago

Actually, after some years away I was able to fix this easily (at least this particular case): https://github.com/bobheadxi/readable/pull/13

m-spitfire commented 1 year ago

Thanks again!