smajumdar commited on
Commit
41b4040
·
verified ·
1 Parent(s): e62ce2b

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -10,7 +10,7 @@ app_file: space.py
10
  ---
11
 
12
  # `gradio_json_markdown`
13
- <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
14
 
15
  JSON module with markdown support
16
 
@@ -38,7 +38,7 @@ data = """
38
  "canonical_form": ""
39
  },
40
  {
41
- "value": "```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
42
  "from": "Assistant",
43
  "canonical_form": ""
44
  }
 
10
  ---
11
 
12
  # `gradio_json_markdown`
13
+ <a href="https://pypi.org/project/gradio_json_markdown/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_json_markdown"></a>
14
 
15
  JSON module with markdown support
16
 
 
38
  "canonical_form": ""
39
  },
40
  {
41
+ "value": "<algorithm>\\n1. Check n is less than or equal to the length of the input list.\\n2. Sort the list.\\n3. Return the maximum of the product of the last 'n' elements or the product of the first 'n' elements.\\n4. The product of the last 'n' elements is the product of the largest 'n' numbers.\\n</algorithm>\\n\\n```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
42
  "from": "Assistant",
43
  "canonical_form": ""
44
  }
app.py CHANGED
@@ -13,7 +13,7 @@ data = """
13
  "canonical_form": ""
14
  },
15
  {
16
- "value": "```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
17
  "from": "Assistant",
18
  "canonical_form": ""
19
  }
 
13
  "canonical_form": ""
14
  },
15
  {
16
+ "value": "<algorithm>\\n1. Check n is less than or equal to the length of the input list.\\n2. Sort the list.\\n3. Return the maximum of the product of the last 'n' elements or the product of the first 'n' elements.\\n4. The product of the last 'n' elements is the product of the largest 'n' numbers.\\n</algorithm>\\n\\n```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
17
  "from": "Assistant",
18
  "canonical_form": ""
19
  }
space.py CHANGED
@@ -21,7 +21,7 @@ with gr.Blocks(
21
  # `gradio_json_markdown`
22
 
23
  <div style="display: flex; gap: 7px;">
24
- <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
25
  </div>
26
 
27
  JSON module with markdown support
@@ -53,7 +53,7 @@ data = \"\"\"
53
  "canonical_form": ""
54
  },
55
  {
56
- "value": "```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
57
  "from": "Assistant",
58
  "canonical_form": ""
59
  }
 
21
  # `gradio_json_markdown`
22
 
23
  <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_json_markdown/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_json_markdown"></a>
25
  </div>
26
 
27
  JSON module with markdown support
 
53
  "canonical_form": ""
54
  },
55
  {
56
+ "value": "<algorithm>\\n1. Check n is less than or equal to the length of the input list.\\n2. Sort the list.\\n3. Return the maximum of the product of the last 'n' elements or the product of the first 'n' elements.\\n4. The product of the last 'n' elements is the product of the largest 'n' numbers.\\n</algorithm>\\n\\n```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
57
  "from": "Assistant",
58
  "canonical_form": ""
59
  }
src/.idea/workspace.xml CHANGED
@@ -4,18 +4,28 @@
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
- <list default="true" id="b53f7e4a-53f1-42ea-8826-4ef9a94fcbb4" name="Changes" comment="" />
 
 
 
 
 
8
  <option name="SHOW_DIALOG" value="false" />
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
  <option name="LAST_RESOLUTION" value="IGNORE" />
12
  </component>
13
  <component name="Git.Settings">
 
 
 
 
 
14
  <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
15
  </component>
16
- <component name="ProjectColorInfo"><![CDATA[{
17
- "associatedIndex": 4
18
- }]]></component>
19
  <component name="ProjectId" id="2lGF9hSwZ5etpPURpEAwT5eDtlA" />
20
  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
21
  <component name="ProjectViewState">
@@ -27,7 +37,8 @@
27
  "keyToString": {
28
  "Python.app (1).executor": "Run",
29
  "Python.app.executor": "Run",
30
- "RunOnceActivity.ShowReadmeOnStart": "true"
 
31
  }
32
  }]]></component>
33
  <component name="RecentsManager">
@@ -90,7 +101,7 @@
90
  <component name="SharedIndexes">
91
  <attachedChunks>
92
  <set>
93
- <option value="bundled-python-sdk-975db3bf15a3-31b6be0877a2-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.18034.82" />
94
  </set>
95
  </attachedChunks>
96
  </component>
@@ -111,11 +122,28 @@
111
  <option name="project" value="LOCAL" />
112
  <updated>1724807493650</updated>
113
  </task>
114
- <option name="localTasksCounter" value="2" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  <servers />
116
  </component>
117
  <component name="VcsManagerConfiguration">
118
  <MESSAGE value="Initial commit" />
119
- <option name="LAST_COMMIT_MESSAGE" value="Initial commit" />
 
120
  </component>
121
  </project>
 
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
+ <list default="true" id="b53f7e4a-53f1-42ea-8826-4ef9a94fcbb4" name="Changes" comment="">
8
+ <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/demo/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/demo/app.py" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/demo/space.py" beforeDir="false" afterPath="$PROJECT_DIR$/demo/space.py" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/frontend/shared/JSONNode.svelte" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/shared/JSONNode.svelte" afterDir="false" />
12
+ </list>
13
  <option name="SHOW_DIALOG" value="false" />
14
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
15
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
16
  <option name="LAST_RESOLUTION" value="IGNORE" />
17
  </component>
18
  <component name="Git.Settings">
19
+ <option name="PREVIOUS_COMMIT_AUTHORS">
20
+ <list>
21
+ <option value="smajumdar &lt;[email protected]&gt;" />
22
+ </list>
23
+ </option>
24
  <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
25
  </component>
26
+ <component name="ProjectColorInfo">{
27
+ &quot;associatedIndex&quot;: 4
28
+ }</component>
29
  <component name="ProjectId" id="2lGF9hSwZ5etpPURpEAwT5eDtlA" />
30
  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
31
  <component name="ProjectViewState">
 
37
  "keyToString": {
38
  "Python.app (1).executor": "Run",
39
  "Python.app.executor": "Run",
40
+ "RunOnceActivity.ShowReadmeOnStart": "true",
41
+ "git-widget-placeholder": "master"
42
  }
43
  }]]></component>
44
  <component name="RecentsManager">
 
101
  <component name="SharedIndexes">
102
  <attachedChunks>
103
  <set>
104
+ <option value="bundled-python-sdk-98f27166c754-ba05f1cad1b1-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-242.21829.153" />
105
  </set>
106
  </attachedChunks>
107
  </component>
 
122
  <option name="project" value="LOCAL" />
123
  <updated>1724807493650</updated>
124
  </task>
125
+ <task id="LOCAL-00002" summary="Add image">
126
+ <option name="closed" value="true" />
127
+ <created>1724809228614</created>
128
+ <option name="number" value="00002" />
129
+ <option name="presentableId" value="LOCAL-00002" />
130
+ <option name="project" value="LOCAL" />
131
+ <updated>1724809228614</updated>
132
+ </task>
133
+ <task id="LOCAL-00003" summary="Add image">
134
+ <option name="closed" value="true" />
135
+ <created>1724809266516</created>
136
+ <option name="number" value="00003" />
137
+ <option name="presentableId" value="LOCAL-00003" />
138
+ <option name="project" value="LOCAL" />
139
+ <updated>1724809266516</updated>
140
+ </task>
141
+ <option name="localTasksCounter" value="4" />
142
  <servers />
143
  </component>
144
  <component name="VcsManagerConfiguration">
145
  <MESSAGE value="Initial commit" />
146
+ <MESSAGE value="Add image" />
147
+ <option name="LAST_COMMIT_MESSAGE" value="Add image" />
148
  </component>
149
  </project>
src/README.md CHANGED
@@ -10,7 +10,7 @@ app_file: space.py
10
  ---
11
 
12
  # `gradio_json_markdown`
13
- <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
14
 
15
  JSON module with markdown support
16
 
@@ -38,7 +38,7 @@ data = """
38
  "canonical_form": ""
39
  },
40
  {
41
- "value": "```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
42
  "from": "Assistant",
43
  "canonical_form": ""
44
  }
 
10
  ---
11
 
12
  # `gradio_json_markdown`
13
+ <a href="https://pypi.org/project/gradio_json_markdown/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_json_markdown"></a>
14
 
15
  JSON module with markdown support
16
 
 
38
  "canonical_form": ""
39
  },
40
  {
41
+ "value": "<algorithm>\\n1. Check n is less than or equal to the length of the input list.\\n2. Sort the list.\\n3. Return the maximum of the product of the last 'n' elements or the product of the first 'n' elements.\\n4. The product of the last 'n' elements is the product of the largest 'n' numbers.\\n</algorithm>\\n\\n```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
42
  "from": "Assistant",
43
  "canonical_form": ""
44
  }
src/backend/gradio_json_markdown/templates/component/index.js CHANGED
The diff for this file is too large to render. See raw diff
 
src/demo/app.py CHANGED
@@ -13,7 +13,7 @@ data = """
13
  "canonical_form": ""
14
  },
15
  {
16
- "value": "```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
17
  "from": "Assistant",
18
  "canonical_form": ""
19
  }
 
13
  "canonical_form": ""
14
  },
15
  {
16
+ "value": "<algorithm>\\n1. Check n is less than or equal to the length of the input list.\\n2. Sort the list.\\n3. Return the maximum of the product of the last 'n' elements or the product of the first 'n' elements.\\n4. The product of the last 'n' elements is the product of the largest 'n' numbers.\\n</algorithm>\\n\\n```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
17
  "from": "Assistant",
18
  "canonical_form": ""
19
  }
src/demo/space.py CHANGED
@@ -21,7 +21,7 @@ with gr.Blocks(
21
  # `gradio_json_markdown`
22
 
23
  <div style="display: flex; gap: 7px;">
24
- <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">
25
  </div>
26
 
27
  JSON module with markdown support
@@ -53,7 +53,7 @@ data = \"\"\"
53
  "canonical_form": ""
54
  },
55
  {
56
- "value": "```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
57
  "from": "Assistant",
58
  "canonical_form": ""
59
  }
 
21
  # `gradio_json_markdown`
22
 
23
  <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_json_markdown/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_json_markdown"></a>
25
  </div>
26
 
27
  JSON module with markdown support
 
53
  "canonical_form": ""
54
  },
55
  {
56
+ "value": "<algorithm>\\n1. Check n is less than or equal to the length of the input list.\\n2. Sort the list.\\n3. Return the maximum of the product of the last 'n' elements or the product of the first 'n' elements.\\n4. The product of the last 'n' elements is the product of the largest 'n' numbers.\\n</algorithm>\\n\\n```python\\ndef largest_product_n(nums, n):\\n if n > len(nums):\\n return \\\"n must be less than or equal to the length of the input list\\\"\\n nums.sort() # sort the list\\n # return the product of the last 'n' elements (largest 'n' numbers) or\\n # the product of the first 'n' elements (smallest 'n' numbers), whichever is greater\\n return max(nums[-n] * nums[-1] *\\n reduce(lambda x, y: x * y, nums[-n:-1], 1),\\n nums[0] * nums[n-1] *\\n reduce(lambda x, y: x * y, nums[1:n], 1))\\n\\n# I used functool's reduce function, so import reduce from functools module\\nfrom functools import reduce\\n\\n# test cases\\nprint(largest_product_n([-10,-20,5,6,7], 3)) # returns 600\\nprint(largest_product_n([-10,-20,5,6,7], 4)) # returns -1400\\nprint(largest_product_n([1,2,3,4,5], 2)) # returns 20\\nprint(largest_product_n([1,2,3,4,5], 6)) # returns \\\"n must be less than or equal to the length of the input list\\\"\\n\\n```\\nPlease note, this code assumes that you always have at least `n` integers in the input list. If this is not the case, you should add a check for this in the function.\\n\\nThe function sorts the integers in the list and checks if the product of the largest `n` integers or the product of the smallest integers (with one exception, explained below) is larger.\\n\\nFor the smallest integers, the function multiplies the smallest integer (nums[0]) with the \\\"n-1\\\"th integer (since the smallest integer is already included), and with the product of all integers between the 1st and the \\\"n-1\\\"th index.\\n\\nFor the largest integers, the function multiplies the largest integer (nums[-1]) with the \\\"n\\\"th integer (with the sign taken into account, since if there are negative integers we want to include as many as possible), and with the product of all integers between the \\\"n\\\"th and the second last index. If all integers are positive, the product of the largest integers is always larger or equal than the product of the smallest integers. If there is one negative integer, the product of the largest integers is always larger, since -1*(-1)*any_positive_number > any_postive_number.\\n\\nThis case is different if there is more than one negative number. If there is more than one negative number, the product of the smallest integers could be larger than the product of the largest integers, since (-n1)*(-n2) > p1*p2, where n1, n2 are negative integers and p1, p2 are positive integers. Since we take the maximum product, this case is also covered.\\n\\nIn Python, indices start from 0 and go up to n-1, so nums[-n] denotes the n-th integer from the right (last 'n' integers), and nums[-1] denotes the last integer, corresponding to the largest integer. Likewise, nums[1:n] denotes the integers between index 1 and index n-1. The reduce function is used to multiply all integers in a range. For example, reduce(lambda x, y: x * y, [1,2,3,4,5]) is equivalent to 1*2*3*4*5, and returns `120`.\\n\\nThe input `n` is the number of integers we want to select to form our product. For this problem, we assume `n >= 2`. This condition should be checked before calling the function. We also assume that the input is a list of integers. The case where `n > len(nums)` is handled by returning an error message. If `n == 1`, the function would still work, but it would not make much sense, since it would always return the largest integer in the input list.",
57
  "from": "Assistant",
58
  "canonical_form": ""
59
  }
src/frontend/shared/JSONNode.svelte CHANGED
@@ -46,9 +46,15 @@
46
  })
47
  );
48
 
 
 
 
 
49
  function toMarkdown(value: string): string {
50
- console.log("Render:" + value);
51
- const parsed = marked.parse(value);
 
 
52
  const parser = new DOMParser();
53
  const doc = parser.parseFromString(parsed, 'text/html');
54
  doc.querySelectorAll('code').forEach((codeElement) => {
 
46
  })
47
  );
48
 
49
+ function escapeXmlTags(value: string): string {
50
+ return value.replace(/</g, '&lt;').replace(/>/g, '&gt;');
51
+ }
52
+
53
  function toMarkdown(value: string): string {
54
+ // console.log("Render:" + value);
55
+ const escapedValue = escapeXmlTags(value);
56
+ console.log("Escaped:" + escapedValue);
57
+ const parsed = marked.parse(escapedValue);
58
  const parser = new DOMParser();
59
  const doc = parser.parseFromString(parsed, 'text/html');
60
  doc.querySelectorAll('code').forEach((codeElement) => {
src/pyproject.toml CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
8
 
9
  [project]
10
  name = "gradio_json_markdown"
11
- version = "0.0.1"
12
  description = "JSON module with markdown support"
13
  readme = "README.md"
14
  license = "apache-2.0"
 
8
 
9
  [project]
10
  name = "gradio_json_markdown"
11
+ version = "0.0.2"
12
  description = "JSON module with markdown support"
13
  readme = "README.md"
14
  license = "apache-2.0"