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

Adds ascii_title to string manipulation #3192

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 5 additions & 2 deletions docs/content/manual/dev/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1856,16 +1856,19 @@ sections:
input: '["a",1,2.3,true,null,false]'
output: ['"a 1 2.3 true false"']

- title: "`ascii_downcase`, `ascii_upcase`"
- title: "`ascii_downcase`, `ascii_upcase`, `ascii_title`"
body: |

Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
converted to the specified case.

examples:
- program: 'ascii_upcase'
- program: "ascii_upcase"
input: '"useful but not for é"'
output: ['"USEFUL BUT NOT FOR é"']
- program: "ascii_title"
input: '"useful but not for é"'
output: ['"Useful But Not For é"']

- title: "`while(cond; update)`"
body: |
Expand Down
5 changes: 4 additions & 1 deletion docs/content/manual/v1.7/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ sections:
input: '["a",1,2.3,true,null,false]'
output: ['"a 1 2.3 true false"']

- title: "`ascii_downcase`, `ascii_upcase`"
- title: "`ascii_downcase`, `ascii_upcase`, `ascii_title`"
body: |

Emit a copy of the input string with its alphabetic characters (a-z and A-Z)
Expand All @@ -1834,6 +1834,9 @@ sections:
- program: "ascii_upcase"
input: '"useful but not for é"'
output: ['"USEFUL BUT NOT FOR é"']
- program: "ascii_title"
input: '"useful but not for é"'
output: ['"Useful But Not For é"']

- title: "`while(cond; update)`"
body: |
Expand Down
8 changes: 6 additions & 2 deletions jq.1.prebuilt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/builtin.jq
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def ascii_downcase:
# like ruby's upcase - only characters a to z are affected
def ascii_upcase:
explode | map( if 97 <= . and . <= 122 then . - 32 else . end) | implode;
def ascii_title:
split(" ") | map(sub("(?<a>.)"; "\(.a|ascii_upcase)")) | join(" ")

# Streaming utilities
def truncate_stream(stream):
Expand Down
4 changes: 4 additions & 0 deletions tests/man.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading