-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve jsonstringify
and stringify
operators docs: part 2
#7748
Merged
Jermolene
merged 1 commit into
Jermolene:tiddlywiki-com
from
mateuszwilczek:improve-jsonstringif-1695299529
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
editions/tw5.com/tiddlers/filters/examples/jsonstringify Operator (Examples).tid
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
created: 20230922121858167 | ||
modified: 20230922122333325 | ||
tags: [[Operator Examples]] [[jsonstringify Operator]] | ||
title: jsonstringify Operator (Examples) | ||
type: text/vnd.tiddlywiki | ||
|
||
Compare the encoding of quotes and control characters in the first example with the analogue [[example for the stringify operator|stringify Operator (Examples)]]. | ||
<<.operator-example 1 """[[Backslash \, double quote ", single quote ', tab , line feed | ||
]] +[jsonstringify[]]""">> | ||
<<.operator-example 2 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 without suffix]] +[jsonstringify[]]""">> | ||
<<.operator-example 3 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 with rawunicode suffix]] +[jsonstringify:rawunicode[]]""">> |
6 changes: 4 additions & 2 deletions
6
editions/tw5.com/tiddlers/filters/examples/stringify_Operator_(Examples).tid
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
created: 20161017154944352 | ||
modified: 20230919124059118 | ||
modified: 20230922122319674 | ||
tags: [[Operator Examples]] [[stringify Operator]] | ||
title: stringify Operator (Examples) | ||
type: text/vnd.tiddlywiki | ||
|
||
<<.operator-example 1 """[[Title with "double quotes" and single ' and \backslash]] +[stringify[]]""">> | ||
Compare the encoding of quotes and control characters in the first example with the analogue [[example for the jsonstringify operator|jsonstringify Operator (Examples)]]. | ||
<<.operator-example 1 """[[Backslash \, double quote ", single quote ', tab , line feed | ||
]] +[stringify[]]""">> | ||
<<.operator-example 2 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 without suffix]] +[stringify[]]""">> | ||
<<.operator-example 3 """[[Accents and emojis -> äñøßπ ⌛🎄🍪🍓 with rawunicode suffix]] +[stringify:rawunicode[]]""">> |
27 changes: 25 additions & 2 deletions
27
editions/tw5.com/tiddlers/filters/jsonstringify Operator.tid
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
caption: jsonstringify | ||
created: 20171029155051467 | ||
from-version: 5.1.14 | ||
modified: 20230919124826880 | ||
modified: 20230922121404577 | ||
op-input: a [[selection of titles|Title Selection]] | ||
op-output: the input with JSON string encodings applied | ||
op-parameter: | ||
op-parameter-name: | ||
op-purpose: deprecated, use <<.olink stringify>> instead | ||
op-purpose: apply JSON string encoding to a string, see also the similar <<.olink stringify>> | ||
op-suffix: <<.from-version "5.1.23">> optionally, the keyword `rawunicode` | ||
op-suffix-name: R | ||
tags: [[Filter Operators]] [[String Operators]] | ||
title: jsonstringify Operator | ||
type: text/vnd.tiddlywiki | ||
|
||
The following substitutions are made: | ||
|
||
|!Character |!Replacement |!Condition | | ||
|`\` |`\\` |Always | | ||
|`"` |`\"` |Always | | ||
|Carriage return (0x0d) |`\r` |Always | | ||
|Line feed (0x0a) |`\n` |Always | | ||
|Backspace (0x08) |`\b` |Always | | ||
|Form field (0x0c) |`\f` |Always | | ||
|Tab (0x09) |`\t` |Always| | ||
|Characters from 0x00 to 0x1f, except listed above |`\u####` where #### is four hex digits |Always | | ||
|Characters from from 0x80 to 0xffff|`\u####` where #### is four hex digits |If `rawunicode` suffix is not present (default) | | ||
|Characters from 0x80 to 0xffff|<<.from-version "5.1.23">> Unchanged |If `rawunicode` suffix is present | | ||
|
||
<<.from-version "5.1.23">> If the suffix `rawunicode` is present, Unicode characters above 0x80 (such as ß, ä, ñ or 🎄) will be passed through unchanged. Without the suffix, they will be substituted with `\u` codes, which was the default behavior before 5.1.23. Characters outside the Basic Multilingual Plane, such as 🎄 and other emojis, will be encoded as a UTF-16 surrogate pair, i.e. with two `\u` sequences. | ||
|
||
<<.note """Mind the differences compared to <<.olink stringify>> in encoding of single quotes and control characters (0x00 to 0x1f). | ||
""">> | ||
|
||
<<.operator-examples "jsonstringify">> |
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No critique here, just a question for the core team. How long do we keep these "New in 5.1.23" annotations around? There's been the entire
5.2.x
train as well as5.3.0
and5.3.1
, and this would likely appear in5.3.2
. Is there some official shelf-life?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! When we introduced the version tags, I was indeed thinking that we'd have some sort of statute of limitations where we'd drop the older ones. We could do it crudely by searching and replacing in an editor, but I'd prefer to update the macro so that it parses the version number and doesn't produce any output if the version is less than some threshold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look into it, together with some other documentation-macro related edits I had in mind. Would a threshold of >= 5.2 be reasonable? That is, everything below 5.2 will be hidden?