Last active
October 27, 2025 13:57
-
-
Save smeech/f7128328215346a89911151cd9800500 to your computer and use it in GitHub Desktop.
[Sentence capitalise] Capitalise new sentence after period, question or exclamation mark. #espanso #regex #bash #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Capitalises first letter after sentence-ending punctuation, skipping exceptions | |
| - regex: (?P<before>\b[\w.]+[.?!])\s(?P<firstchar>[a-z])(?P<therest>\w*\W) | |
| replace: "{{before}} {{capital}}{{therest}}" | |
| vars: | |
| - name: capital | |
| type: script | |
| params: | |
| args: | |
| - python | |
| - -c | |
| - | | |
| exceptions = {"etc.", "i.e.", "e.g.", "Prof."} | |
| print("{{firstchar}}" if "{{before}}" in exceptions else "{{firstchar}}".upper()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Capitalise new sentence after period, question or exclamation mark, skip "etc." | |
| - regex: (?P<before>\b[\w.]+[.?!])\s(?P<firstchar>[a-z])(?P<therest>\w*\W) | |
| replace: "{{before}} {{capital}}{{therest}}" | |
| vars: | |
| - name: capital | |
| type: shell | |
| params: | |
| cmd: | | |
| EXCEPTIONS=("etc." "i.e." "e.g." "Prof.") | |
| # Check if 'before' exactly matches any exception | |
| if printf "%s\n" "${EXCEPTIONS[@]}" | grep -Fxq "{{before}}"; then | |
| echo "{{firstchar}}" # leave lowercase | |
| else | |
| echo "{{firstchar}}" | tr '[:lower:]' '[:upper:]' | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment