-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: new Rule to capitalize bulleted list items #1239
Comments
@x-thompson3 , could you elaborate a little on what you mean by custom regex not supporting |
@pjkaufman here's an example note:
If I set a custom regex rule as
Whereas it to works as expected with regex101.com: I also realized that if this capitalization was done solely using the custom regex, there might be edge cases where the capitalization is undesirable (iOS and similar lower-case proper nouns, frontmatter list-type properties). An actual Linter rule is probably the preferred solution to make use of an ignore-list. |
I do agree that to handle edge cases like exceptions to words to capitalize it would be best to have a program handle the capitalization to fine tune things, but I am not sure if the Linter is the right place for this. It could be neat, but as it stands it seems niche to me. It may be something that users want, but at this time I see little indication of that. For now, I can leave this open and see if any other users would like this feature and close it if it is not something users would like. |
I'm new to the Linter plugin. Can you explain how to enter this code in the Linter plugin? I also wanted to capitalize the first letter of the first word in a list. Thanks. |
@magi44ken and anyone else interested in the implementation I ended up using:
Caveats
|
@magi44ken , to add a rule to the Linter, I would recommend reading the documentation on adding a rule located here. You would definitely want to use the helper function for editing list item text called updateListItemText. It is used a couple of places for updating the text of a list item. Hopefully this helps in at least getting started. I will try my best to make time to answer questions as they come up. |
@x-thompson3 , the Linter internally keeps track of the last active leaf on file change. I don't believe that is accessible outside of the plugin. It is located on a private property called lastActiveFile. You probably cannot access it directly, but you can always try. Also, the macro might work for linting all files in a vault/folder, but it would depend on some logic that has not been proven to work in the Linter. But it in theory would work. I just would not rely on it working. The reason the logic runs twice for the macro when you have Lint on File Change (content change) enabled is because the Linter has no idea what changes are made by custom commands or even when they finish with certainty (this is the logic that I mentioned before that has not been thoroughly tested, but tries its best). So the Linter sees the change made by the Macro as Obsidian or a user change. Thus it kicks off the Linter logic again. It is potentially possible to ignore the custom command logic for Linter changes, but that may be bugging and cause unexpected results since the Linter has no control over it. Hopefully this helps better understand some of the limitations you hit. |
Is Your Feature Request Related to a Problem? Please Describe.
I'd love for Linter to be able to format bulleted lists so that the first word of the list is capitalized. It's clean, consistent, and saves some effort for mobile users of Obsidian.
Describe the Solution You'd Like
A new Rule created that, when enabled, capitalizes the first word of bulleted lists, regardless of indentation level. Perhaps needs an ignore-list for words like 'iPhone' and the like.
Please include an example where applicable:
Before:
After:
Describe Alternatives You've Considered
The Custom Regex option doesn't support the
\U
case modifier, which was my first attempted implementation.I tried creating a QuickAdd Macro, but the documentation is a little sparse. Below is what I scraped together, which had two problems:
Lint on Focused Field Change
, the file that gets changed is the file that I switch to, instead of the one I'm leaving (presumably because I'm getting the content fromparams.app.workspace.activeLeaf.view.editor
)Lint on save
andLint on Focused File Change
, this macro gets run twice somehow whenever Linter calls it. I haven't been able to figure out why.Additional Context
None.
The text was updated successfully, but these errors were encountered: