Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

[FEATURE REQUEST] Every sentence on new-line for readability and maintainability #133

Open
BroodjeKroepoek opened this issue Dec 6, 2023 · 16 comments

Comments

@BroodjeKroepoek
Copy link

Currently as of version 0.2.7 (46b4ec3)

Long sentences get split up by adding a newline in the middle. Which is good.

But I would also like to have every sentence on a newline, since this won't impact paragraphs in Typst (same for LaTeX).

Normally I do this manually, I scroll trough the file and put a newline behind every period.

I would be nice if the formatter did this automatically.

@astrale-sharp
Copy link
Owner

Hey there :)

We could simply add a newline after each single . in text mode then

This should be feasible

@BroodjeKroepoek
Copy link
Author

Thanks for the quick response!

Maybe I'll look into proposing a pull-request myself, if this feature doesn't have that high of a priority. Im not as familiar with the codebase just yet, so i'll have to learn, but im loving using the formatter anyways!

@astrale-sharp
Copy link
Owner

Thanks for your kind words ❤️

I'd ideally like to work on it myself but unfortunately, I'm spending lots of my energy looking for a job right now so PR's are very encouraged ;)

@BroodjeKroepoek
Copy link
Author

BroodjeKroepoek commented Dec 6, 2023

Now that I think about it a bit more...

Maybe if we accept this feature request, it would be not good to also split long sentences by newline in the middle.
Since the file you're working in will get very long.

The reason that every sentence on a newline is nice is because you get a certain style guide and certainty.
If you are working on a thesis, and you use git to track changes, this will also help with maintainability.

If you still want to have the long sentences being broken up, you can just turn on word wrap (in visual studio code). But I also understand the need to support people that don't use IDE's that have these features.

See image: https://user-images.githubusercontent.com/610782/76849727-31ec9400-6803-11ea-808f-b632975d67f0.png

But splitting sentences in the middle also makes for a pretty square end result.

I would love to hear, your thoughts on this.

@astrale-sharp
Copy link
Owner

Long in number of lines? I actually think it would be pretty okay to have both (especially since the default line length is quite long and configurable.)

It would be a bit subtle and possibly hacky to have both at once though so I'm not sure If I actually want to support that 🤔

@avonmoll
Copy link

I was going to request this feature as well. There is some relevant discussion here for vimtex (a comprehensive vim package for LaTeX which includes its own formatexpr). I agree that mixing one line per sentence with maximum line length could be a bit odd, but I guess I could go either way on that point. One thing to watch out for would be that we wouldn't want to split the line after certain periods in text mode. For example, Mr., Mrs., e.g., c.f., etc., and maybe other commonly used abbreviations.

@astrale-sharp
Copy link
Owner

lot's of abbreviation in fact yes, good remark! Maybe we should only split on . if there is an uppercase letter after it? that feels a bit silly 🤔

@avonmoll
Copy link

avonmoll commented Dec 11, 2023

That's closer, but it still doesn't work for Mr. Hammond is a person.. It would put a line break after Mr. since the next letter is uppercase.

@astrale-sharp
Copy link
Owner

astrale-sharp commented Dec 11, 2023

Hmm 🤔 anyone has an idea? what is a sentence? 🤣

@avonmoll
Copy link

This project may give some ideas. For a quick solution it may be fine to implement your initial idea with a few manual exceptions (e.g., don't break after Mrs., Mr., Dr., Drs.).

@astrale-sharp
Copy link
Owner

There's also the possibility/need to let the user add manual exceptions via the config file!

@astrale-sharp
Copy link
Owner

It starts to get complicated if we want to support multiple languages tho :(

(e.g., don't break after Mrs., Mr., Dr., Drs.).

@avonmoll
Copy link

avonmoll commented Dec 12, 2023

You are absolutely correct. A "good enough" solution for me would be a configurable option for typstfmt to just not reflow my paragraphs since I'm already so used to manually writing one-sentence-per-line.

@astrale-sharp
Copy link
Owner

That's actually already the case, you can use word_wrap = false in config

@avonmoll
Copy link

avonmoll commented Dec 12, 2023

Maybe I'm missing something in the documentation but where am I supposed to place typstfmt.toml? (I'm on macos)


Edit: I found it! (via typstfmt --get-global-config-path)

@astrale-sharp
Copy link
Owner

there's also typstfmt -C that creates a new local to the project config file! at ./typstfmt.toml I think!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants