kivikakk / comrak

CommonMark + GFM compatible Markdown parser and renderer
Other
1.12k stars 133 forks source link

Feat/inplace: add new parameter `--inplace` (`-i`) for in-place formatting #377

Closed bioinformatist closed 2 months ago

bioinformatist commented 2 months ago

Some clippy lints also have been fixed separately 😺

kivikakk commented 2 months ago

Thank you, this looks excellent.

I really appreciate the extra clippy fixes! I know in the past that some of these changes caused issues for people because it caused an increase in the MSRV (see https://github.com/kivikakk/comrak/issues/290), but I think it's been long enough that I'm happy to move on. Still, before I merge, I'm going to compare the lib and bin MSRVs before and after this change, just for my own reference, and make an appropriate declaration in Cargo.toml.

Thank you again! :white_heart:

kivikakk commented 2 months ago

OK! in-place itself specifies an MSRV of 1.70 (or 1.65 for in-place 0.1.0), but I don't really care about the binary's MSRV. I've made in-place an optional dependency and added it to the cli feature.

Now we get an MSRV of 1.62.1, compared with 1.60.0 on main. This seems completely fine to me — thanks again!

digitalmoksha commented 1 month ago

@bioinformatist just curious, is there any difference between

cargo run -- --inplace test.md

and

cargo run -- --to commonmark --output test.md test.md

It seems to work the same for me 🤔

kivikakk commented 1 month ago

It is the same, and it should be! And it's fine for it to be 👍 We could expand -i to allow specifying multiple files in future, or directories.

digitalmoksha commented 1 month ago

Sounds good to me. One thought I had was if the option was set we might be able to just set the proper to and output options internally. But then we wouldn't be able to easily expand into multiple files, which would be desirable.