tealdeer-rs / tealdeer

A very fast implementation of tldr in Rust.
https://tealdeer-rs.github.io/tealdeer/
Apache License 2.0
4.17k stars 123 forks source link

Refactor formatting code #189

Closed niklasmohrin closed 3 years ago

niklasmohrin commented 3 years ago

See this discussion.

This aims to introduce some abstractions where needed and refactor code that has accumulated complexity over time

niklasmohrin commented 3 years ago

@dbrgn I bumped MSRV to 1.52 here because I wanted to use str::split_once. Like I said, I don't really see why we would have to support older versions of the compiler. Are you okay with that or do you see any problems?

niklasmohrin commented 3 years ago

Tests are complaining about highlighting, but I think it looks fine. I checked the binary output and it seems that the current implementation outputs more color modifiers than what I refactored it to (left / "stable.out" is current impl, right / "master.out" is this PR)

image

$ du *.out --bytes
1471    master.out
1542    stable.out

Can someone take a look that knows exactly what is important for the coloring? It looks just fine to me :smile: @SimplyDanny

niklasmohrin commented 3 years ago

@dbrgn @SimplyDanny I think I managed to include everything I had in mind, your turn :)

niklasmohrin commented 3 years ago

@dbrgn In case you feel like merging this PR, please make sure not to squash the history, so that we can keep the documentation I put in the commits

dbrgn commented 3 years ago

I think only the renamings and a rebase against master are left until we can merge this!