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

Support for diacritics by changing interpreter from Python 2 to Python 3 #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Change Case.alfredworkflow
Binary file not shown.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Change Case — Workflow for Alfred

Changes the case of text selected, provided, or on the clipboard to UPPERCASE, lowercase, Title Case, CamelCase, kebab-case, or snake_case.
Changes the case of text selected, provided, or on the clipboard to UPPERCASE, lowercase, Title Case, CamelCase, kebab-case, or snake_case. Now works with diacritics.

[Download the workflow](https://github.com/gillibrand/alfred-change-case/blob/master/Change%20Case.alfredworkflow).
[Download the workflow](https://github.com/bpetrynski/alfred-change-case/releases/).

Python 3 is required, [install it before use](https://installpython3.com/mac/).

![Screenshot](changecase.png)

Expand All @@ -14,6 +16,9 @@ Optionally, any text typed after `case` will be changed instead of the clipboard

## Version History

### 4/8/2021
- Support for diacritics by changing interpreter from Python 2 to Python 3.

### 9/9/2018

- Added CamelCase, kebab-case, and snake_case options
Expand Down
29 changes: 15 additions & 14 deletions changecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from xml.sax.saxutils import escape
from titlecase import titlecase


if len(sys.argv) > 1 and len(sys.argv[1].strip()):
text = sys.argv[1]
else:
Expand Down Expand Up @@ -36,37 +37,37 @@ def upcase(m):

}

print """<?xml version="1.0"?>
print("""<?xml version="1.0"?>
<items>
<item arg="%(lower)s">
<title>%(lower)s</title>
<subtitle>lowercase</subtitle>
<title>"%(lower)s"</title>
<subtitle>Transform text to `lowercase`</subtitle>
<icon>lowercase.png</icon>
</item>
<item arg="%(upper)s">
<title>%(upper)s</title>
<subtitle>UPPERCASE</subtitle>
<title>"%(upper)s"</title>
<subtitle>Transform text to `UPPERCASE`</subtitle>
<icon>uppercase.png</icon>
</item>
<item arg="%(title)s">
<title>%(title)s</title>
<subtitle>Title Case</subtitle>
<title>"%(title)s"</title>
<subtitle>Transform text to `Title Case`</subtitle>
<icon>titlecase.png</icon>
</item>
<item arg="%(camel)s">
<title>%(camel)s</title>
<subtitle>CamelCase</subtitle>
<title>"%(camel)s"</title>
<subtitle>Transform text to `CamelCase`</subtitle>
<icon>camelcase.png</icon>
</item>
<item arg="%(kebab)s">
<title>%(kebab)s</title>
<subtitle>kebab-case</subtitle>
<title>"%(kebab)s"</title>
<subtitle>Transform text to hyphenated `kebab-case`</subtitle>
<icon>kebabcase.png</icon>
</item>
<item arg="%(snake)s">
<title>%(snake)s</title>
<subtitle>snake_case</subtitle>
<title>"%(snake)s"</title>
<subtitle>Transform text to `snake_case`</subtitle>
<icon>snakecase.png</icon>
</item>

</items>""" % variations
</items>""" % variations)