Repository: tldr-pages/tldr-python-client (language: python)

Issue:
Coloring for printed { } is broken
![image](https://user-images.githubusercontent.com/42812113/150630464-a39f5f33-e2d3-4476-a13a-11d274bba991.png)

Sample tldr page:

```yml
# awk

> A versatile programming language for working on files.
> See also: `sed`, `ed`.
> More information: <https://manned.org/awk.1>.

- Execute commands:

`awk '{{{ print gensub("apple", "mango", "g") }}}'`

```

The last `}` displayed must be red too.
Coloring for printed { } is broken
![image](https://user-images.githubusercontent.com/42812113/150630464-a39f5f33-e2d3-4476-a13a-11d274bba991.png)

Sample tldr page:

```yml
# awk

> A versatile programming language for working on files.
> See also: `sed`, `ed`.
> More information: <https://manned.org/awk.1>.

- Execute commands:

`awk '{{{ print gensub("apple", "mango", "g") }}}'`

```

The last `}` displayed must be red too.


Discussion / hints:
I'm not sure what exactly you're looking for here. Is it that `{ }` characters shouldn't be removed? That the `}` character is not colored the same as the rest of the example? Happy to help try to address this, but I'm at a loss one what the user expectation is as I don't use `awk` that much so none of these commands much sense to me.
> That the } character is not colored the same as the rest of the example?

Yes. The problem is not addressed to just `awk`. It happens with other pages for instance for `cat file.json | jq '{my_new_key: .key_name, my_other_key: .other_key_name}'` command sample.
I'm not sure what exactly you're looking for here. Is it that `{ }` characters shouldn't be removed? That the `}` character is not colored the same as the rest of the example? Happy to help try to address this, but I'm at a loss one what the user expectation is as I don't use `awk` that much so none of these commands much sense to me.
> That the } character is not colored the same as the rest of the example?

Yes. The problem is not addressed to just `awk`. It happens with other pages for instance for `cat file.json | jq '{my_new_key: .key_name, my_other_key: .other_key_name}'` command sample.

Fix patch:
diff --git a/tldr.py b/tldr.py
index 8acfbf4..57f48eb 100755
--- a/tldr.py
+++ b/tldr.py
@@ -296,7 +296,7 @@ def get_page(
 
 LEADING_SPACES_NUM = 2
 
-COMMAND_SPLIT_REGEX = re.compile(r'(?P<param>{{.+?}})')
+COMMAND_SPLIT_REGEX = re.compile(r'(?P<param>{{.+?}*}})')
 PARAM_REGEX = re.compile(r'(?:{{)(?P<param>.+?)(?:}})')
 
 


Test patch:
diff --git a/tests/data/jq.md b/tests/data/jq.md
new file mode 100644
index 0000000..0da5616
--- /dev/null
+++ b/tests/data/jq.md
@@ -0,0 +1,37 @@
+# jq
+
+> A command-line JSON processor that uses a domain-specific language.
+> More information: <https://stedolan.github.io/jq>.
+
+- Output a JSON file, in pretty-print format:
+
+`jq . {{file.json}}`
+
+- Output all elements from arrays (or all the values from objects) in a JSON file:
+
+`jq '.[]' {{file.json}}`
+
+- Read JSON objects from a file into an array, and output it (inverse of `jq .[]`):
+
+`jq --slurp . {{file.json}}`
+
+- Output the first element in a JSON file:
+
+`jq '.[0]' {{file.json}}`
+
+- Output the value of a given key of each element in a JSON text from stdin:
+
+`cat {{file.json}} | jq 'map(.{{key_name}})'`
+
+- Output the value of multiple keys as a new JSON object (assuming the input JSON has the keys `key_name` and `other_key_name`):
+
+`cat {{file.json}} | jq '{{{my_new_key}}: .{{key_name}}, {{my_other_key}}: .{{other_key_name}}}'`
+
+- Combine multiple filters:
+
+`cat {{file.json}} | jq 'unique | sort | reverse'`
+
+- Output the value of a given key to a string (and disable JSON output):
+
+`cat {{file.json}} | jq --raw-output '"some text: \(.{{key_name}})"'`
+
diff --git a/tests/data/jq_rendered b/tests/data/jq_rendered
new file mode 100644
index 0000000..f850dbf
--- /dev/null
+++ b/tests/data/jq_rendered
@@ -0,0 +1,30 @@
+
+  [1mjq[0m
+
+  A command-line JSON processor that uses a domain-specific language.[0m
+  More information: https://stedolan.github.io/jq.[0m
+
+  [32m- Output a JSON file, in pretty-print format:[0m
+    [31mjq . [0mfile.json[0m[31m[0m
+
+  [32m- Output all elements from arrays (or all the values from objects) in a JSON file:[0m
+    [31mjq '.[]' [0mfile.json[0m[31m[0m
+
+  [32m- Read JSON objects from a file into an array, and output it (inverse of `jq .[]`):[0m
+    [31mjq --slurp . [0mfile.json[0m[31m[0m
+
+  [32m- Output the first element in a JSON file:[0m
+    [31mjq '.[0]' [0mfile.json[0m[31m[0m
+
+  [32m- Output the value of a given key of each element in a JSON text from stdin:[0m
+    [31mcat [0mfile.json[0m[31m | jq 'map(.[0mkey_name[0m[31m)'[0m
+
+  [32m- Output the value of multiple keys as a new JSON object (assuming the input JSON has the keys `key_name` and `other_key_name`):[0m
+    [31mcat [0mfile.json[0m[31m | jq '[0m{my_new_key[0m[31m: .[0mkey_name[0m[31m, [0mmy_other_key[0m[31m: .[0mother_key_name[0m}[31m'[0m
+
+  [32m- Combine multiple filters:[0m
+    [31mcat [0mfile.json[0m[31m | jq 'unique | sort | reverse'[0m
+
+  [32m- Output the value of a given key to a string (and disable JSON output):[0m
+    [31mcat [0mfile.json[0m[31m | jq --raw-output '"some text: \(.[0mkey_name[0m[31m)"'[0m
+
diff --git a/tests/test_tldr.py b/tests/test_tldr.py
index 1d3c02f..0ed0dd1 100644
--- a/tests/test_tldr.py
+++ b/tests/test_tldr.py
@@ -6,10 +6,15 @@
 import types
 from unittest import mock
 
+# gem is a basic test of page rendering
+# jq is a more complicated test for token parsing
+page_names = ('gem', 'jq')
 
-def test_whole_page():
-    with open("tests/data/gem.md", "rb") as f_original:
-        with open("tests/data/gem_rendered", "rb") as f_rendered:
+
+@pytest.mark.parametrize("page_name", page_names)
+def test_whole_page(page_name):
+    with open(f"tests/data/{page_name}.md", "rb") as f_original:
+        with open(f"tests/data/{page_name}_rendered", "rb") as f_rendered:
             old_stdout = sys.stdout
             sys.stdout = io.StringIO()
             sys.stdout.buffer = types.SimpleNamespace()
@@ -24,8 +29,9 @@ def test_whole_page():
             assert tldr_output == correct_output
 
 
-def test_markdown_mode():
-    with open("tests/data/gem.md", "rb") as f_original:
+@pytest.mark.parametrize("page_name", page_names)
+def test_markdown_mode(page_name):
+    with open(f"tests/data/{page_name}.md", "rb") as f_original:
         d_original = f_original.read()
         old_stdout = sys.stdout
         sys.stdout = io.StringIO()