summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/jsonparse
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-12-02 03:03:40 +0000
committerNorbert Preining <norbert@preining.info>2024-12-02 03:03:40 +0000
commitd8a57fb296b6897829f0ae703b0b32f00bd1ba20 (patch)
tree7c944117747aaea12f3f6f75f442c2233c404261 /macros/latex/contrib/jsonparse
parent2c8ea3287e3d336f2d0bb0f57f0b1d7bd9221ab6 (diff)
CTAN sync 202412020303
Diffstat (limited to 'macros/latex/contrib/jsonparse')
-rw-r--r--macros/latex/contrib/jsonparse/README.md2
-rw-r--r--macros/latex/contrib/jsonparse/jsonparse-doc.pdfbin519126 -> 518865 bytes
-rw-r--r--macros/latex/contrib/jsonparse/jsonparse-doc.tex8
-rw-r--r--macros/latex/contrib/jsonparse/jsonparse.sty90
4 files changed, 56 insertions, 44 deletions
diff --git a/macros/latex/contrib/jsonparse/README.md b/macros/latex/contrib/jsonparse/README.md
index dc7757b826..dc55f60663 100644
--- a/macros/latex/contrib/jsonparse/README.md
+++ b/macros/latex/contrib/jsonparse/README.md
@@ -1,4 +1,4 @@
-![Version 0.9.8](https://img.shields.io/badge/version-0.9.8-blue)
+![Version 0.9.9](https://img.shields.io/badge/version-0.9.9-blue)
![Jason, the JSON parsing horse](https://github.com/jasperhabicht/jsonparse/assets/6378801/ddfddc70-bf5f-4121-ba45-4b9128875d85)
diff --git a/macros/latex/contrib/jsonparse/jsonparse-doc.pdf b/macros/latex/contrib/jsonparse/jsonparse-doc.pdf
index 1555c7088a..997f8cbf47 100644
--- a/macros/latex/contrib/jsonparse/jsonparse-doc.pdf
+++ b/macros/latex/contrib/jsonparse/jsonparse-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/jsonparse/jsonparse-doc.tex b/macros/latex/contrib/jsonparse/jsonparse-doc.tex
index 897f68cbca..f71c448bff 100644
--- a/macros/latex/contrib/jsonparse/jsonparse-doc.tex
+++ b/macros/latex/contrib/jsonparse/jsonparse-doc.tex
@@ -11,8 +11,8 @@
% This work has the LPPL maintenance status `maintained'.
%
\documentclass[a4paper]{article}
-\def\jsonparsefileversion{0.9.8}
-\def\jsonparsefiledate{30 November 2024}
+\def\jsonparsefileversion{0.9.9}
+\def\jsonparsefiledate{1 December 2024}
\usepackage[T1]{fontenc}
\usepackage{Alegreya}
@@ -339,7 +339,7 @@ For example, if the JSON string \macro{{ "key" : "value" }} has been parsed into
\begin{macrodef}
|\JSONParseSetValue|{<token variable>}{<token variable>}{<key>}
\end{macrodef}
-The expandable command \macro{\JSONParseValueSet} can be used to a select a value from the token variable that stores the parsed JSON data via a key and store this value in another token variable.
+The command \macro{\JSONParseValueSet} can be used to a select a value from the token variable that stores the parsed JSON data via a key and store this value globally in another token variable.
The first argument denotes the token variable where the value should be stored into. If this token variable has not yet been defined, it will be created by this command. The second argument represents the token variable (property list) that has been created using the commands \macro{\JSONParse} or \macro{\JSONParseFromFile} and that stores the parsed JSON data. The third argument takes the key to select the relevant value.
@@ -348,7 +348,7 @@ The token list returned by this command is a string variable where all character
\begin{macrodef}
|\JSONParseSetRescanValue|{<token variable>}{<token variable>}{<key>}
\end{macrodef}
-The expandable command \macro{\JSONParseSetRescanValue} works the same way and also takes the same arguments as \macro{\JSONParseSetValue} except that it rescans the return value before storing it in the token variable. This means that the value stored in the token list will have the category codes TeX uses per default.
+The command \macro{\JSONParseSetRescanValue} works the same way and also takes the same arguments as \macro{\JSONParseSetValue} except that it rescans the return value before storing it globally in the token variable. This means that the value stored in the token list will have the category codes TeX uses per default.
This can, for example, be necessary when numbers stored in the JSON data in scientific format should be formatted using the \macro{siunitx} package. The rescan is needed here, because otherwise the character \macro{e} would have the wrong category code and would hence not be recognised by the formatting parser as exponent marker. Let us assume the key \macro{number} in some JSON source parsed into the token variable \macro{\myJSONnumber} represents the value \macro{-1.1e-1}, then the following could be used to format the output:
diff --git a/macros/latex/contrib/jsonparse/jsonparse.sty b/macros/latex/contrib/jsonparse/jsonparse.sty
index a8e21835b4..23b4a5b5e0 100644
--- a/macros/latex/contrib/jsonparse/jsonparse.sty
+++ b/macros/latex/contrib/jsonparse/jsonparse.sty
@@ -10,7 +10,7 @@
%
% This work has the LPPL maintenance status `maintained'.
%
-\ProvidesExplPackage {jsonparse} {2024-11-30} {0.9.8}
+\ProvidesExplPackage {jsonparse} {2024-12-01} {0.9.9}
{A handy way to parse, store and access JSON data from files or strings in LaTeX documents}
\bool_new:N \l__jsonparse_debug_mode_bool
@@ -237,7 +237,7 @@
\cs_generate_variant:Nn \file_input:n { e }
\cs_generate_variant:Nn \tl_gset:Nn { Ne , ce }
-\cs_generate_variant:Nn \tl_gset_rescan:Nnn { Nne }
+\cs_generate_variant:Nn \tl_gset_rescan:Nnn { Nno , Nne }
\cs_generate_variant:Nn \tl_range:nnn { nne , nen }
\cs_generate_variant:Nn \tl_range:Nnn { Nne , Nen }
\cs_generate_variant:Nn \tl_remove_once:Nn { NV }
@@ -955,61 +955,73 @@
\symbol{ " \str_uppercase:n { #1 #2 #3 #4 } } { }
}
+\cs_new:Npn \__jsonparse_rescan_setup:Nn #1#2 {
+ \cs_set:Npn \" { " }
+ \cs_set:Npn \/ { / }
+ \cs_set:Npn \\ { \c_backslash_str }
+ \cs_set:Npn \b { \l__jsonparse_backspace_str }
+ \cs_set:Npn \f { \l__jsonparse_formfeed_str }
+ \cs_set:Npn \n { \l__jsonparse_linefeed_str }
+ \cs_set:Npn \r { \l__jsonparse_carriage_return_str }
+ \cs_set:Npn \t { \l__jsonparse_horizontal_tab_str }
+ \cs_set_eq:NN \u \__jsonparse_unicode_char:NNNN
+ \tl_set:Ne #1 {#2}
+ \cs_set_eq:NN \" \__jsonparse_tex_quote:
+ \cs_set_eq:NN \\ \__jsonparse_tex_backslash:
+ \bool_if:NT \l__jsonparse_escape_number_sign_bool {
+ \tl_replace_all:Noe #1 { \c_hash_str } { \c_backslash_str \c_hash_str }
+ }
+ \bool_if:NT \l__jsonparse_escape_dollar_sign_bool {
+ \tl_replace_all:Noe #1 { \c_dollar_str } { \c_backslash_str \c_dollar_str }
+ }
+ \bool_if:NT \l__jsonparse_escape_percent_sign_bool {
+ \tl_replace_all:Noe #1 { \c_percent_str } { \c_backslash_str \c_percent_str }
+ }
+ \bool_if:NT \l__jsonparse_escape_ampersand_bool {
+ \tl_replace_all:Noe #1 { \c_ampersand_str } { \c_backslash_str \c_ampersand_str }
+ }
+ \bool_if:NT \l__jsonparse_escape_circumflex_accent_bool {
+ \tl_replace_all:Non #1 { \c_circumflex_str } { \textasciicircum }
+ }
+ \bool_if:NT \l__jsonparse_escape_low_line_bool {
+ \tl_replace_all:Noe #1 { \c_underscore_str } { \c_backslash_str \c_underscore_str }
+ }
+ \bool_if:NT \l__jsonparse_escape_tilde_bool {
+ \tl_replace_all:Non #1 { \c_tilde_str } { \textasciitilde }
+ }
+}
+
\cs_new:Npn \__jsonparse_rescan:n #1 {
\group_begin:
- \cs_set:Npn \" { " }
- \cs_set:Npn \/ { / }
- \cs_set:Npn \\ { \c_backslash_str }
- \cs_set:Npn \b { \l__jsonparse_backspace_str }
- \cs_set:Npn \f { \l__jsonparse_formfeed_str }
- \cs_set:Npn \n { \l__jsonparse_linefeed_str }
- \cs_set:Npn \r { \l__jsonparse_carriage_return_str }
- \cs_set:Npn \t { \l__jsonparse_horizontal_tab_str }
- \cs_set_eq:NN \u \__jsonparse_unicode_char:NNNN
- \tl_set:Ne \l__jsonparse_temp_tl {#1}
- \cs_set_eq:NN \" \__jsonparse_tex_quote:
- \cs_set_eq:NN \\ \__jsonparse_tex_backslash:
- \bool_if:NT \l__jsonparse_escape_number_sign_bool {
- \tl_replace_all:Noe \l__jsonparse_temp_tl { \c_hash_str } { \c_backslash_str \c_hash_str }
- }
- \bool_if:NT \l__jsonparse_escape_dollar_sign_bool {
- \tl_replace_all:Noe \l__jsonparse_temp_tl { \c_dollar_str } { \c_backslash_str \c_dollar_str }
- }
- \bool_if:NT \l__jsonparse_escape_percent_sign_bool {
- \tl_replace_all:Noe \l__jsonparse_temp_tl { \c_percent_str } { \c_backslash_str \c_percent_str }
- }
- \bool_if:NT \l__jsonparse_escape_ampersand_bool {
- \tl_replace_all:Noe \l__jsonparse_temp_tl { \c_ampersand_str } { \c_backslash_str \c_ampersand_str }
- }
- \bool_if:NT \l__jsonparse_escape_circumflex_accent_bool {
- \tl_replace_all:Non \l__jsonparse_temp_tl { \c_circumflex_str } { \textasciicircum }
- }
- \bool_if:NT \l__jsonparse_escape_low_line_bool {
- \tl_replace_all:Noe \l__jsonparse_temp_tl { \c_underscore_str } { \c_backslash_str \c_underscore_str }
- }
- \bool_if:NT \l__jsonparse_escape_tilde_bool {
- \tl_replace_all:Non \l__jsonparse_temp_tl { \c_tilde_str } { \textasciitilde }
- }
+ \__jsonparse_rescan_setup:Nn \l__jsonparse_temp_tl {#1}
\tl_rescan:no { } { \l__jsonparse_temp_tl }
\group_end:
}
+\cs_new:Npn \__jsonparse_gset_rescan:Nn #1#2 {
+ \group_begin:
+ \__jsonparse_rescan_setup:Nn \l__jsonparse_temp_tl {#2}
+ \tl_gset_rescan:Nno #1 { } { \l__jsonparse_temp_tl }
+ \group_end:
+}
+\cs_generate_variant:Nn \__jsonparse_gset_rescan:Nn { Ne }
+
\NewExpandableDocumentCommand { \JSONParseExpandableValue } { m m } {
\prop_item:Ne #1 {#2}
}
-\NewExpandableDocumentCommand { \JSONParseSetValue } { m m m } {
+\NewDocumentCommand { \JSONParseSetValue } { m m m } {
\tl_if_exist:NF #1 {
\tl_new:N #1
}
- \tl_set:Nne #1 { \prop_item:Ne #2 {#3} }
+ \tl_set:Ne #1 { \prop_item:Ne #2 {#3} }
}
-\NewExpandableDocumentCommand { \JSONParseSetRescanValue } { m m m } {
+\NewDocumentCommand { \JSONParseSetRescanValue } { m m m } {
\tl_if_exist:NF #1 {
\tl_new:N #1
}
- \tl_set_rescan:Nne #1 { } { \prop_item:Ne #2 {#3} }
+ \__jsonparse_gset_rescan:Ne #1 { \prop_item:Ne #2 {#3} }
}
\NewDocumentCommand { \JSONParseValue } { O{} m m } {