33import plugins
44
55from helpers_for_testing import verify_in_json_format_to_markdown
6+ from plugins import Plugin
7+ from tests .helpers_for_testing import verify_in_json_format_to_markdown
68from utils import FileGroups
79
810
911def verify_plugin (manifest_as_json : str , plugin_as_json : str ) -> None :
12+ plugin = process_plugin (manifest_as_json , plugin_as_json )
13+ verify_in_json_format_to_markdown (plugin .data ())
14+
15+
16+ def process_plugin (manifest_as_json : str , plugin_as_json : str ) -> Plugin :
1017 plugin = plugins .Plugin (json .loads (plugin_as_json ))
1118 manifest = json .loads (manifest_as_json )
1219 file_groups : FileGroups = dict ()
1320 result = plugin .collect_data_for_plugin_and_manifest (manifest , file_groups )
14- verify_in_json_format_to_markdown ( plugin . data ())
21+ return plugin
1522
1623
1724def test_author_augmented_for_ryanjamurphy () -> None :
@@ -65,3 +72,39 @@ def test_author_missing_from_manifest() -> None:
6572 }
6673 '''
6774 verify_plugin (manifest_as_json , plugin_as_json )
75+
76+
77+ def test_description_contains_newline () -> None :
78+ # See https://github.com/obsidian-community/obsidian-hub/issues/791
79+ # This plugin's manifest.json has a newline character in the description.
80+ # This test verifies that this situation is handled correctly.
81+ plugin_as_json = '''
82+ {
83+ "id": "attachment-manager",
84+ "name": "Attachment Manager",
85+ "author": "chenfeicqq",
86+ "description": "Attachment Manager: Attachment folder name binding note name, automatically rename, automatically delete, show/hide.\\ n附件管理器:附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。",
87+ "repo": "chenfeicqq/obsidian-attachment-manager"
88+ }
89+ '''
90+ plugin_from_obsidian_releases = plugins .Plugin (json .loads (plugin_as_json ))
91+ assert plugin_from_obsidian_releases .data ()['description' ] == "Attachment Manager: Attachment folder name binding note name, automatically rename, automatically delete, show/hide. 附件管理器:附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。"
92+
93+ manifest_as_json = '''
94+ {
95+ "id": "attachment-manager",
96+ "name": "Attachment Manager",
97+ "version": "1.2.2",
98+ "minAppVersion": "0.12.17",
99+ "description": "Attachment folder name binding note name, automatically rename, automatically delete, show/hide.\\ n附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。",
100+ "author": "chenfeicqq",
101+ "authorUrl": "https://github.com/chenfeicqq",
102+ "isDesktopOnly": true
103+ }
104+ '''
105+
106+ plugin_from_obsidian_releases_and_manifest = process_plugin (manifest_as_json , plugin_as_json )
107+ assert plugin_from_obsidian_releases_and_manifest .data ()['description' ] == "Attachment folder name binding note name, automatically rename, automatically delete, show/hide. 附件文件夹名称绑定笔记名、自动重命名、自动删除、显示/隐藏。"
108+
109+ verify_plugin (manifest_as_json , plugin_as_json )
110+
0 commit comments