Skip to content

Commit

Permalink
Merge pull request #71069 from Qrox/nbsp
Browse files Browse the repository at this point in the history
Remove non-breaking spaces from JSON strings and make JSON formatter replace nbsp with escape sequence
  • Loading branch information
Maleclypse committed Feb 16, 2024
2 parents e1833dd + 86391d6 commit 93c658a
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 424 deletions.
828 changes: 414 additions & 414 deletions data/json/ascii_art/generic_ascii.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/json/items/containers/conversions.json
Expand Up @@ -57,7 +57,7 @@
"category": "container",
"name": { "str": "standard rifle conversion kit" },
"looks_like": "box_small",
"description": "This is a sturdy cardboard box, stamped with manufacturer markings and emblazoned with the stylized image of an assembled rifle.  Containing appropriate retool components for an average weapon platform, including upper receiver assemblies, swappable barrels, and assorted extras (such as magazines), its contents could be used to rechamber a compatible rifle.",
"description": "This is a sturdy cardboard box, stamped with manufacturer markings and emblazoned with the stylized image of an assembled rifle. Containing appropriate retool components for an average weapon platform, including upper receiver assemblies, swappable barrels, and assorted extras (such as magazines), its contents could be used to rechamber a compatible rifle.",
"weight": "400 g",
"volume": "6880 ml",
"longest_side": "43 cm",
Expand Down
6 changes: 3 additions & 3 deletions data/json/items/gun/303.json
Expand Up @@ -5,13 +5,13 @@
"looks_like": "modular_ar15",
"type": "GUN",
"name": { "str": "Enfield battle rifle" },
"description": "An iconic weapon of both the First and Second World Wars, this bolt-action rifle has seen deployment in the hands of Commonwealth troops across Europe and beyond.  Firing the .303-caliber cartridge and making use of 10-round Enfield magazines, the firearm’s reputation precedes it.",
"description": "An iconic weapon of both the First and Second World Wars, this bolt-action rifle has seen deployment in the hands of Commonwealth troops across Europe and beyond. Firing the .303-caliber cartridge and making use of 10-round Enfield magazines, the firearm’s reputation precedes it.",
"variant_type": "gun",
"variants": [
{
"id": "smle_mk3",
"name": { "str": "SMLE No. 1 Mk III rifle" },
"description": "An English darling and icon of the First World War, the Short Magazine Lee-Enfield Mk III was the standard issue battle rifle of the British commonwealth from 1907.  Chambered for .303 ammunition, the rifle makes use of ten-round detachable magazines.  With its full-length wooden handguard, brass buttplate, and smooth action, the Lee-Enfield cuts a recognizable profile in either the trenches of the Great War or the zombie-strewn wastelands."
"description": "An English darling and icon of the First World War, the Short Magazine Lee-Enfield Mk III was the standard issue battle rifle of the British commonwealth from 1907. Chambered for .303 ammunition, the rifle makes use of ten-round detachable magazines. With its full-length wooden handguard, brass buttplate, and smooth action, the Lee-Enfield cuts a recognizable profile in either the trenches of the Great War or the zombie-strewn wastelands."
}
],
"weight": "3960 g",
Expand Down Expand Up @@ -58,7 +58,7 @@
{
"id": "number4_mki",
"name": { "str": "Lee-Enfield No. 4 Mk I rifle" },
"description": "A Second World War progression of the British Commonwealth's Lee-Enfield battle rifle, the No. 4 began its decades-long service life in 1939.  Externally similar to its forefather, the rifle possesses a reinforced receiver, an adjusted nose cap, and a heavier barrel.  Still chambered for the same .303-caliber cartridge, the No. 4 represents one of the most populous firearm imports in U.S. history."
"description": "A Second World War progression of the British Commonwealth's Lee-Enfield battle rifle, the No. 4 began its decades-long service life in 1939. Externally similar to its forefather, the rifle possesses a reinforced receiver, an adjusted nose cap, and a heavier barrel. Still chambered for the same .303-caliber cartridge, the No. 4 represents one of the most populous firearm imports in U.S. history."
}
],
"weight": "4110 g",
Expand Down
4 changes: 2 additions & 2 deletions data/json/npcs/random_encounters/john_bailey.json
Expand Up @@ -177,8 +177,8 @@
"u_has_var": "John_Bailey_Convo",
"context": "RC_John_Bailey_2",
"value": "seen",
"yes": "Like I said,\" John shrugs. \"I'm just checking ",
"no": "Same as you, I imagine,\" John shrugs. \"Checking "
"yes": "Like I said,\" John shrugs. \"I'm just checking ",
"no": "Same as you, I imagine,\" John shrugs. \"Checking "
},
"the place out, doing a little shopping. Then I'll be on my way again. Might see if they have any work that needs done first, if the price is right."
]
Expand Down
2 changes: 1 addition & 1 deletion data/json/snippets/lab.json
Expand Up @@ -336,7 +336,7 @@
},
{
"id": "mutation_testing_3",
"text": "Prepare subject with 2000 U mutagen\nApply 500 U primer compound\nObserve for 6 hours\nResults: The subject felt a painful headache\nLong-term results: the subject developed a heavy form of psychosis, including heavy hallucinations, delirium, and schizophrenia.  The subject was neutralized during an attempt to pull a sidearm from a security guard's holster."
"text": "Prepare subject with 2000 U mutagen\nApply 500 U primer compound\nObserve for 6 hours\nResults: The subject felt a painful headache\nLong-term results: the subject developed a heavy form of psychosis, including heavy hallucinations, delirium, and schizophrenia. The subject was neutralized during an attempt to pull a sidearm from a security guard's holster."
},
{
"id": "mutation_testing_4",
Expand Down
4 changes: 2 additions & 2 deletions data/json/snippets/photos.json
Expand Up @@ -14,7 +14,7 @@
},
{
"id": "wallet_picture_3",
"text": "This is a rather aged Polaroid photo, creased from having spent years being folded and unfolded in succession. A smiling young man dressed in an olive-drab flight suit stands in the foreground, framed by the open doorway of an UH-1 Huey helicopter, a gloved hand gripping the door, a flight helmet and pushed-up aviator’s goggles perched upon his head, and a jaunty thumbs-up directed towards the camera. In shaky handwriting, the back of the picture is marked with the caption, \"September 10th, 1967.\"\n\nIn smaller script, someone’s written, \"still missing in action. May you fly on in our hearts.\""
"text": "This is a rather aged Polaroid photo, creased from having spent years being folded and unfolded in succession. A smiling young man dressed in an olive-drab flight suit stands in the foreground, framed by the open doorway of an UH-1 Huey helicopter, a gloved hand gripping the door, a flight helmet and pushed-up aviator’s goggles perched upon his head, and a jaunty thumbs-up directed towards the camera. In shaky handwriting, the back of the picture is marked with the caption, \"September 10th, 1967.\"\n\nIn smaller script, someone’s written, \"still missing in action. May you fly on in our hearts.\""
},
{
"id": "wallet_picture_4",
Expand Down Expand Up @@ -142,7 +142,7 @@
},
{
"id": "wallet_picture_35",
"text": "This is a blurry photo taken in bright daylight.  A dog sits in the middle of the frame with a ball in its mouth; its fur is completely caked in mud.  Two kids are seen to the left playing in a nearby pond—most likely the cause of the dog's soiled fur.  On the back, a message reads, \"You had a long run. I still miss you, always.\""
"text": "This is a blurry photo taken in bright daylight. A dog sits in the middle of the frame with a ball in its mouth; its fur is completely caked in mud. Two kids are seen to the left playing in a nearby pond—most likely the cause of the dog's soiled fur. On the back, a message reads, \"You had a long run. I still miss you, always.\""
},
{
"id": "wallet_picture_36",
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Xedra_Evolved/mutations/temporary.json
Expand Up @@ -69,7 +69,7 @@
"active": true,
"points": 1,
"visibility": 1,
"description": "Your eyes transform into the orbits of an unknown creature.  You now see much better in the light and dark.",
"description": "Your eyes transform into the orbits of an unknown creature. You now see much better in the light and dark.",
"//": "not actual replacement yet, because i'm afraid of how wearing stuff may interact with it",
"valid": false,
"starting_trait": false,
Expand Down
9 changes: 9 additions & 0 deletions tools/format/format.cpp
Expand Up @@ -85,6 +85,15 @@ void formatter::format( TextJsonIn &jsin, JsonOut &jsout, int depth, bool force_
std::string str = jsin.substr( start_pos, end_pos - start_pos );
str = str.substr( str.find( '"' ) );
str = str.substr( 0, str.rfind( '"' ) + 1 );
// Replace non-breaking space with escape sequence to avoid confusion.
// Since JSON cannot have an nbsp inside an escape sequence this will
// produce syntactically valid output as long as the input is
// syntactically valid, which `get_string` should have already checked.
static const std::string nbsp = "\u00A0";
for( size_t pos = str.find( nbsp ); pos != std::string::npos; pos = str.find( nbsp, pos ) ) {
str.replace( pos, nbsp.size(), R"(\u00A0)" );
}
// Write the string
jsout.write_separator();
*jsout.get_stream() << str;
jsout.set_need_separator();
Expand Down

0 comments on commit 93c658a

Please sign in to comment.