Skip to content
Closed
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
21 changes: 21 additions & 0 deletions packages/escape/1.0.2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Dickson Law

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions packages/escape/1.0.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Escape Text

A simple Espanso package for encoding and decoding various common escape formats in programming (JSON, XML, URL-encoding, regular expressions)

## Requirements

- Python 3.x
- Espanso 2.x or higher

## Installation

```
espanso install escape
```

## Usage

### Encoding

All encoding triggers start with `>>`

| Trigger | Conversion |
|-----------|---------|
| `>>json` | Text -> JSON/backslash |
| `>>xml` | Text -> XML |
| `>>url` | Text -> URL encoding |
| `>>regex` | Text -> Regular expression literal |

### Decoding

All decoding triggers start with `<<`

| Trigger | Conversion |
|-----------|---------|
| `<<json` | JSON/backslash -> Text |
| `<<xml` | XML -> Text |
| `<<url` | URL encoding -> Text |
7 changes: 7 additions & 0 deletions packages/escape/1.0.2/_manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
author: Dickson Law
description: Common character escapes (backslashing, JSON, XML, URL-encoding, regex)
title: Escape Text
name: escape
homepage: https://github.com/dicksonlaw583/espanso-escape
version: 1.0.2
tags: ["json", "xml", "backslash", "url encoding", "x-www-form-urlencoded", "escape"]
2 changes: 2 additions & 0 deletions packages/escape/1.0.2/_pkgsource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
hub
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/jsonescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from json import dumps as escape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(escape(sys.argv[1])[1:-1], end='')
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/jsonunescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from json import loads as unescape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(unescape('"%s"' % (sys.argv[1])), end='')
133 changes: 133 additions & 0 deletions packages/escape/1.0.2/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
global_vars:
- name: escape_python
type: echo
params:
echo: "python" # Replace this with the path to your Python instance if automatic detection is failing

matches:
- triggers: [">>json", ">>\\"]
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "JSON/backslash escape\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/jsonescape.py"
- "{{f.text}}"
- triggers: ["<<json", "<<\\"]
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "JSON/backslash un-escape\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/jsonunescape.py"
- "{{f.text}}"
- trigger: ">>xml"
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "XML escape\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/xmlescape.py"
- "{{f.text}}"
- trigger: "<<xml"
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "XML un-escape\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/xmlunescape.py"
- "{{f.text}}"
- trigger: ">>url"
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "URL encode\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/urlescape.py"
- "{{f.text}}"
- trigger: "<<url"
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "URL decode\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/urlunescape.py"
- "{{f.text}}"
- trigger: ">>regex"
replace: "{{stdout}}"
vars:
- name: "f"
type: form
params:
layout: "Regex escape\n\nText:\n[[text]]"
fields:
text:
multiline: true
- name: stdout
type: script
params:
trim: false
args:
- "{{escape_python}}"
- "%CONFIG%/match/packages/escape/regexescape.py"
- "{{f.text}}"
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/regexescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from re import escape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(escape(sys.argv[1]), end='')
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/urlescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from urllib.parse import quote_plus as escape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(escape(sys.argv[1]), end='')
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/urlunescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from urllib.parse import unquote_plus as unescape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(unescape(sys.argv[1]), end='')
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/xmlescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from xml.sax.saxutils import escape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(escape(sys.argv[1]), end='')
6 changes: 6 additions & 0 deletions packages/escape/1.0.2/xmlunescape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys
from xml.sax.saxutils import unescape

if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
print(unescape(sys.argv[1]), end='')
21 changes: 21 additions & 0 deletions packages/repeat/1.0.2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Dickson Law

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions packages/repeat/1.0.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Repeat

A simple package for typing a piece of text on repeat.

## Requirements

- Espanso 2.x or higher
- Python 3.x

## Installation

```
espanso install repeat
```

## Triggers

| Trigger | Description |
|-----------|---------|
| `;rep` (first character is a semicolon `;`) | Repeat a piece of text N times. |
| `:rep` (first character is a colon `:`) | Repeat a text template over each row of a list of items. |
| `^rep` | Repeat a text template over each row of a list of items (with customizable separators and support for row columns). |
7 changes: 7 additions & 0 deletions packages/repeat/1.0.2/_manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
author: Dickson Law
description: Utility for typing text on repeat.
title: Repeat
name: repeat
homepage: https://github.com/dicksonlaw583/espanso-repeat
version: 1.0.2
tags: ["repeat", "repetition", "repetitive"]
2 changes: 2 additions & 0 deletions packages/repeat/1.0.2/_pkgsource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
hub
10 changes: 10 additions & 0 deletions packages/repeat/1.0.2/foreach.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys, json

if __name__ == '__main__':
# Syntax: foreach.py <template> <separator> <placeholder> <items>
sys.stdout.reconfigure(encoding='utf-8')
template = sys.argv[1]
separator = json.loads('"%s"' % (sys.argv[2]))
placeholder = sys.argv[3]
items = sys.argv[4].split("\n")
print(separator.join([template.replace(placeholder, item) for item in items]), end='')
21 changes: 21 additions & 0 deletions packages/repeat/1.0.2/foreach_ext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys, json

def fillTemplate(template, placeholderFormat, item):
'''
Fill the template with the given item list, and return the result.
'''
result = template
for i in range(len(item)):
result = result.replace(placeholderFormat.replace('N', str(i)), item[i])
return result

if __name__ == '__main__':
# Syntax: foreach_ext.py <template> <placeholderformat> <rowseparator> <columnseparator> <items> <itemseparator>
sys.stdout.reconfigure(encoding='utf-8')
template = sys.argv[1]
placeholderFormat = sys.argv[2]
rowSeparator = json.loads('"%s"' % (sys.argv[3]))
columnSeparator = json.loads('"%s"' % (sys.argv[4]))
items = [rowString.split(columnSeparator) for rowString in sys.argv[5].split(rowSeparator)]
itemSeparator = json.loads('"%s"' % (sys.argv[6]))
print(itemSeparator.join([fillTemplate(template, placeholderFormat, item) for item in items]), end='')
Loading
Loading