Skip to content

Commit d35455f

Browse files
committed
Update npm publish script and package keywords
1 parent 3352675 commit d35455f

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

package.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,28 @@
7979
"keywords": [
8080
"react",
8181
"component",
82+
"components",
8283
"interactive",
8384
"interactive-json",
8485
"json",
8586
"json-component",
8687
"json-display",
8788
"json-tree",
88-
"json-view",
8989
"json-viewer",
9090
"json-inspector",
9191
"json-schema",
92+
"json-editor",
93+
"editor",
94+
"data-viewer",
95+
"form-builder",
96+
"drag-and-drop",
97+
"customizable",
98+
"typescript",
9299
"react-component",
93100
"react-json",
94-
"react18-json-view",
95-
"react-json-view",
96101
"theme",
97-
"tree",
98102
"tree-view",
99-
"treeview"
103+
"treeview",
104+
"react-json-view"
100105
]
101106
}

scripts/build_npm_readme.py

+35-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
without duplicating it.
88
99
It also converts Github-style admonition blocks to HTML that mimics Github
10-
styling.
10+
styling and converts internal anchor links to full GitHub repository URLs.
1111
"""
1212

1313
import re
@@ -74,16 +74,41 @@ def replace_admonition(match):
7474

7575
return re.sub(pattern, replace_admonition, text, flags=re.MULTILINE)
7676

77-
def replace_blocks(content_file, source_file, output_file=None):
77+
def convert_internal_links(text, base_url="https://github.com/CarlosNZ/json-edit-react"):
7878
"""
79-
Replace blocks in the content file with corresponding blocks from the source file.
80-
Ignores block markers inside Markdown comments.
79+
Convert internal Markdown anchor links to full GitHub documentation links.
80+
81+
Args:
82+
text (str): The input text containing internal links
83+
base_url (str): The base URL for the GitHub repository
84+
85+
Returns:
86+
str: Text with converted links
87+
"""
88+
# Regex to match internal Markdown links: [text](#anchor)
89+
# But avoid matching links that already have a full URL or are not anchors
90+
pattern = r'\[([^\]]+)\]\(#([^)]+)\)'
91+
92+
def replace_link(match):
93+
link_text = match.group(1)
94+
anchor = match.group(2)
95+
96+
# Create the full GitHub URL with the anchor
97+
return f'[{link_text}]({base_url}#{anchor})'
98+
99+
return re.sub(pattern, replace_link, text)
100+
101+
def replace_blocks(content_file, source_file, output_file=None, base_url="https://github.com/CarlosNZ/json-edit-react"):
102+
"""
103+
Replace blocks in the content file with corresponding blocks from the source file,
104+
and convert internal links to full GitHub links.
81105
82106
Args:
83107
content_file (str): Path to the content markdown file
84108
source_file (str): Path to the source markdown file
85109
output_file (str, optional): Path to save the modified content.
86-
If None, returns the modified content.
110+
If None, returns the modified content.
111+
base_url (str): The base URL for the GitHub repository
87112
88113
Returns:
89114
str: Modified content if no output file is specified
@@ -119,6 +144,9 @@ def replace_non_comment_blocks(match):
119144
# Convert Github admonition blocks
120145
modified_content = convert_github_admonition(modified_content)
121146

147+
# Convert internal links to full GitHub links
148+
modified_content = convert_internal_links(modified_content, base_url)
149+
122150
# If output file is specified, write to file
123151
if output_file:
124152
with open(output_file, 'w', encoding='utf-8') as f:
@@ -133,7 +161,8 @@ def main():
133161
replace_blocks(
134162
content_file='README_npm.md',
135163
source_file='README.md',
136-
output_file='README_npm_output.md'
164+
output_file='README_npm_output.md',
165+
base_url="https://github.com/CarlosNZ/json-edit-react"
137166
)
138167

139168
if __name__ == '__main__':

0 commit comments

Comments
 (0)