Skip to content
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

Package star-rating for Espanso #157

Merged
merged 12 commits into from
Mar 7, 2025
Merged

Package star-rating for Espanso #157

merged 12 commits into from
Mar 7, 2025

Conversation

jacobfresco
Copy link
Contributor

A new package Espanso; display a star-rating anywhere you want.

Copy link
Collaborator

@smeech smeech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

A small script package with a single trigger and no apparently malicious code. A couple of minor changes required to rename readme.md, and correct _manifest.yml (or change the name of the package).

As the script is so short, I would suggest setting it inline rather than including a separate file, e.g.:

  - regex: :st(?P<fstars>\d+),(?P<estars>\d+)
    replace: "{{stars}}"
    vars:
      - name: stars
        type: script
        params:
          args:
           - python
           - -c
           - |
            import sys, codecs

            # Ensure UTF-8 output
            sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())

            print(chr(0x2605)*{{fstars}}+chr(0x2606)*{{estars}})
  • I have removed the double-quotes around the regex: to obviate the need to escape the backslashes.
  • Without a terminating character, the final + in the regex: string is redundant as it'll always match a single digit
  • The error-checking, and int float conversions aren't required because the regex: won't trigger at all if the text following :st doesn't consist of two integers separated by a comma.
  • I note the UTF-8 configuration doesn't match that suggested in the docs, but perhaps you want to ensure it'll work with versions of Python pre-3.7.
  • The final line could be print('★' * {{fstars}} + '☆' * {{estars}}) for clarity, but it's a personal choice.

@jacobfresco jacobfresco requested a review from smeech March 7, 2025 15:19
Minor edit
@smeech smeech merged commit 55ceb16 into espanso:main Mar 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants