Skip to content

Commit 21b99f4

Browse files
Feat/cs 44004 json rte nested list fragment (#21)
* Fixed snyk issues and added auto publish package support in github ac… (#19) * Fixed snyk issues and added auto publish package support in github action. (#18) * Fixed snyk issues and added auto publish package support in github ac… (#20) * Fixed snyk issues and added auto publish package support in github action. * Added security file and updated license * Updated changelog file message * Updated python version in github action file * Updated pip and pylint * Added fragment style attribute in JSON RTE nested list Updated License file.
1 parent 4097dc9 commit 21b99f4

File tree

7 files changed

+132
-3
lines changed

7 files changed

+132
-3
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2023 Contentstack
1+
Copyright 2024 Contentstack
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

changelog.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
================
22
**CHANGELOG**
33
================
4+
*v1.2.3*
5+
============
6+
7+
NEW FEATURE: Added Fragment attribute.
8+
9+
- added new style attribute fragment
10+
11+
*v1.2.2*
12+
============
13+
14+
NEW FEATURE: Minor bug fixes and code improvements.
15+
16+
- package release support added
17+
18+
*v1.2.1*
19+
============
20+
21+
NEW FEATURE: GraphQL SRTE
22+
23+
- GraphQL SRTE support added
24+
425

526
*v1.2.2*
627
============

contentstack_utils/render/options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def render_node(node_type, node_obj: dict, callback):
113113
return "<blockquote>" + inner_html + "</blockquote>"
114114
if node_type == 'code':
115115
return "<code>" + inner_html + "</code>"
116+
if node_type == 'fragment':
117+
return "<fragment>" + inner_html + "</fragment>"
116118
if node_type in ['doc', 'reference']:
117119
return inner_html
118120
else:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
long_description_content_type="text/markdown",
1616
url="https://github.com/contentstack/contentstack-utils-python",
1717
license='MIT',
18-
version='1.2.2',
18+
version='1.2.3',
1919
install_requires=[
2020

2121
],

tests/mocks/supercharged/results/Results.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
blockquoteHtml = "<blockquote>Praesent eu ex sed nibh venenatis pretium.</blockquote>"
3131
codeHtml = "<code>Code template.</code>"
3232
linkInPHtml = "<p><strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\">LINK</a></p>"
33+
nested_order_list_with_fragment = "<ol><li><fragment>List Item 1</fragment><ol><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ol></li></ol>"
34+
nested_unorder_list_with_fragment = "<ul><li><fragment>List Item 1</fragment><ul><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ul></li></ul>"

tests/mocks/supercharged/supercharged.json

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,9 +1745,103 @@
17451745
],
17461746
"type": "doc"
17471747
},
1748+
"nested_order_list_with_fragment": {
1749+
"type": "ol",
1750+
"children": [
1751+
{
1752+
"type": "li",
1753+
"children": [
1754+
{
1755+
"type": "fragment",
1756+
"children": [
1757+
{
1758+
"text": "List Item 1"
1759+
}
1760+
]
1761+
},
1762+
{
1763+
"type": "ol",
1764+
"children": [
1765+
{
1766+
"type": "li",
1767+
"children": [
1768+
{
1769+
"text": "List Item 1.1"
1770+
}
1771+
]
1772+
},
1773+
{
1774+
"type": "li",
1775+
"children": [
1776+
{
1777+
"text": "List Item 1.2"
1778+
}
1779+
]
1780+
},
1781+
{
1782+
"type": "li",
1783+
"children": [
1784+
{
1785+
"text": "List Item 1.3"
1786+
}
1787+
]
1788+
}
1789+
]
1790+
}
1791+
]
1792+
}
1793+
]
1794+
},
1795+
"nested_unorder_list_with_fragment": {
1796+
"type": "ul",
1797+
"children": [
1798+
{
1799+
"type": "li",
1800+
"children": [
1801+
{
1802+
"type": "fragment",
1803+
"children": [
1804+
{
1805+
"text": "List Item 1"
1806+
}
1807+
]
1808+
},
1809+
{
1810+
"type": "ul",
1811+
"children": [
1812+
{
1813+
"type": "li",
1814+
"children": [
1815+
{
1816+
"text": "List Item 1.1"
1817+
}
1818+
]
1819+
},
1820+
{
1821+
"type": "li",
1822+
"children": [
1823+
{
1824+
"text": "List Item 1.2"
1825+
}
1826+
]
1827+
},
1828+
{
1829+
"type": "li",
1830+
"children": [
1831+
{
1832+
"text": "List Item 1.3"
1833+
}
1834+
]
1835+
}
1836+
]
1837+
}
1838+
]
1839+
}
1840+
]
1841+
},
17481842
"tags": [],
17491843
"title": "Test Rich Text",
17501844
"updated_at": "2021-06-01T11:59:18.036Z",
17511845
"updated_by": "removed_for_security_reasons",
17521846
"url": "/test-rich-text"
1753-
}
1847+
}

tests/test_util_srte.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,13 @@ def test_linkin_list_in_supercharged_dict_to_html(self):
112112
# array_str = ['reference']
113113
# Utils.json_to_html([self._json_data], array_str, Options())
114114
# self.assertEqual(Results.linkInPHtml, self._json_data['reference'])
115+
116+
def test_nested_order_list_in_supercharged_dict_to_html(self):
117+
array_str = ['nested_order_list_with_fragment']
118+
Utils.json_to_html([self._json_data], array_str, Options())
119+
self.assertEqual(Results.nested_order_list_with_fragment, "<ol><li><fragment>List Item 1</fragment><ol><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ol></li></ol>")
120+
121+
def test_nested_unorder_list_in_supercharged_dict_to_html(self):
122+
array_str = ['nested_unorder_list_with_fragment']
123+
Utils.json_to_html([self._json_data], array_str, Options())
124+
self.assertEqual(Results.nested_unorder_list_with_fragment, "<ul><li><fragment>List Item 1</fragment><ul><li>List Item 1.1</li><li>List Item 1.2</li><li>List Item 1.3</li></ul></li></ul>")

0 commit comments

Comments
 (0)