RayLee commited on
Commit
0d12144
·
verified ·
1 Parent(s): 5584590

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -45,39 +45,8 @@ Here are some important points:
45
  3. Third item with `inline code`
46
  4. Fourth item containing [a link](https://example.com)
47
 
48
- #### Unordered Lists
49
- - Bullet point one
50
- - Bullet point two with **bold text**
51
- - Final bullet point
52
 
53
- ### Code Block Example
54
- ```python
55
- def hello_world():
56
- print("Hello, World!")
57
- return "success"
58
- ```
59
-
60
- ### Tables
61
- | Column 1 | Column 2 | Column 3 |
62
- |----------|----------|----------|
63
- | Cell 1 | Cell 2 | Cell 3 |
64
- | Data A | Data B | Data C |
65
-
66
- ### Blockquotes
67
- > This is a blockquote with some **important** information.
68
- >
69
- > It can span multiple lines and contain *emphasis*.
70
-
71
- ### Mixed Content
72
- The document contains various **formatting** options including:
73
-
74
- - *Italicized text* for emphasis
75
- - **Bold text** for importance
76
- - `Inline code` for technical terms
77
- - Links like [this one](https://example.com)
78
-
79
- #### Final Section
80
- This concludes our comprehensive example with multiple markdown elements for testing position-based highlighting accuracy.""",
81
  "highlights": [
82
  {
83
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
@@ -99,28 +68,7 @@ This concludes our comprehensive example with multiple markdown elements for tes
99
  "content": "Position-based highlight",
100
  "category": "Position Demo",
101
  "color": "#ffeb3b"
102
- },
103
- {
104
- "position": [989, 999],
105
- "title": "Italicized",
106
- "content": "Highlighting 'Italicized'",
107
- "category": "Position Demo",
108
- "color": "#ff9800"
109
- },
110
- {
111
- "term": "formatting",
112
- "title": "formatting (Term Match)",
113
- "content": "Highlighted using term matching - will match anywhere this term appears.",
114
- "category": "Term Demo",
115
- "color": "#d0167f91"
116
- },
117
- {
118
- "position": [30, 37],
119
- "title": "regression test",
120
- "content": "Highlight across lines should not render",
121
- "category": "Position Demo",
122
- "color": "#ffeb3b"
123
- },
124
  ]
125
  }
126
 
 
45
  3. Third item with `inline code`
46
  4. Fourth item containing [a link](https://example.com)
47
 
 
 
 
 
48
 
49
+ """,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  "highlights": [
51
  {
52
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
 
68
  "content": "Position-based highlight",
69
  "category": "Position Demo",
70
  "color": "#ffeb3b"
71
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  ]
73
  }
74
 
space.py CHANGED
@@ -59,40 +59,7 @@ Here are some important points:
59
  2. *Second item* - Another important point
60
  3. Third item with `inline code`
61
  4. Fourth item containing [a link](https://example.com)
62
-
63
- #### Unordered Lists
64
- - Bullet point one
65
- - Bullet point two with **bold text**
66
- - Final bullet point
67
-
68
- ### Code Block Example
69
- ```python
70
- def hello_world():
71
- print("Hello, World!")
72
- return "success"
73
- ```
74
-
75
- ### Tables
76
- | Column 1 | Column 2 | Column 3 |
77
- |----------|----------|----------|
78
- | Cell 1 | Cell 2 | Cell 3 |
79
- | Data A | Data B | Data C |
80
-
81
- ### Blockquotes
82
- > This is a blockquote with some **important** information.
83
- >
84
- > It can span multiple lines and contain *emphasis*.
85
-
86
- ### Mixed Content
87
- The document contains various **formatting** options including:
88
-
89
- - *Italicized text* for emphasis
90
- - **Bold text** for importance
91
- - `Inline code` for technical terms
92
- - Links like [this one](https://example.com)
93
-
94
- #### Final Section
95
- This concludes our comprehensive example with multiple markdown elements for testing position-based highlighting accuracy.\"\"\",
96
  "highlights": [
97
  {
98
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
@@ -114,28 +81,7 @@ This concludes our comprehensive example with multiple markdown elements for tes
114
  "content": "Position-based highlight",
115
  "category": "Position Demo",
116
  "color": "#ffeb3b"
117
- },
118
- {
119
- "position": [989, 999],
120
- "title": "Italicized",
121
- "content": "Highlighting 'Italicized'",
122
- "category": "Position Demo",
123
- "color": "#ff9800"
124
- },
125
- {
126
- "term": "formatting",
127
- "title": "formatting (Term Match)",
128
- "content": "Highlighted using term matching - will match anywhere this term appears.",
129
- "category": "Term Demo",
130
- "color": "#d0167f91"
131
- },
132
- {
133
- "position": [30, 37],
134
- "title": "regression test",
135
- "content": "Highlight across lines should not render",
136
- "category": "Position Demo",
137
- "color": "#ffeb3b"
138
- },
139
  ]
140
  }
141
 
 
59
  2. *Second item* - Another important point
60
  3. Third item with `inline code`
61
  4. Fourth item containing [a link](https://example.com)
62
+ \"\"\",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  "highlights": [
64
  {
65
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
 
81
  "content": "Position-based highlight",
82
  "category": "Position Demo",
83
  "color": "#ffeb3b"
84
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ]
86
  }
87
 
src/README.md CHANGED
@@ -45,39 +45,8 @@ Here are some important points:
45
  3. Third item with `inline code`
46
  4. Fourth item containing [a link](https://example.com)
47
 
48
- #### Unordered Lists
49
- - Bullet point one
50
- - Bullet point two with **bold text**
51
- - Final bullet point
52
 
53
- ### Code Block Example
54
- ```python
55
- def hello_world():
56
- print("Hello, World!")
57
- return "success"
58
- ```
59
-
60
- ### Tables
61
- | Column 1 | Column 2 | Column 3 |
62
- |----------|----------|----------|
63
- | Cell 1 | Cell 2 | Cell 3 |
64
- | Data A | Data B | Data C |
65
-
66
- ### Blockquotes
67
- > This is a blockquote with some **important** information.
68
- >
69
- > It can span multiple lines and contain *emphasis*.
70
-
71
- ### Mixed Content
72
- The document contains various **formatting** options including:
73
-
74
- - *Italicized text* for emphasis
75
- - **Bold text** for importance
76
- - `Inline code` for technical terms
77
- - Links like [this one](https://example.com)
78
-
79
- #### Final Section
80
- This concludes our comprehensive example with multiple markdown elements for testing position-based highlighting accuracy.""",
81
  "highlights": [
82
  {
83
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
@@ -99,28 +68,7 @@ This concludes our comprehensive example with multiple markdown elements for tes
99
  "content": "Position-based highlight",
100
  "category": "Position Demo",
101
  "color": "#ffeb3b"
102
- },
103
- {
104
- "position": [989, 999],
105
- "title": "Italicized",
106
- "content": "Highlighting 'Italicized'",
107
- "category": "Position Demo",
108
- "color": "#ff9800"
109
- },
110
- {
111
- "term": "formatting",
112
- "title": "formatting (Term Match)",
113
- "content": "Highlighted using term matching - will match anywhere this term appears.",
114
- "category": "Term Demo",
115
- "color": "#d0167f91"
116
- },
117
- {
118
- "position": [30, 37],
119
- "title": "regression test",
120
- "content": "Highlight across lines should not render",
121
- "category": "Position Demo",
122
- "color": "#ffeb3b"
123
- },
124
  ]
125
  }
126
 
 
45
  3. Third item with `inline code`
46
  4. Fourth item containing [a link](https://example.com)
47
 
 
 
 
 
48
 
49
+ """,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  "highlights": [
51
  {
52
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
 
68
  "content": "Position-based highlight",
69
  "category": "Position Demo",
70
  "color": "#ffeb3b"
71
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  ]
73
  }
74
 
src/backend/gradio_markdownlabel/templates/component/index.js CHANGED
The diff for this file is too large to render. See raw diff
 
src/build.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ gradio cc build --no-generate-docs --bump-version
src/demo/space.py CHANGED
@@ -59,40 +59,7 @@ Here are some important points:
59
  2. *Second item* - Another important point
60
  3. Third item with `inline code`
61
  4. Fourth item containing [a link](https://example.com)
62
-
63
- #### Unordered Lists
64
- - Bullet point one
65
- - Bullet point two with **bold text**
66
- - Final bullet point
67
-
68
- ### Code Block Example
69
- ```python
70
- def hello_world():
71
- print("Hello, World!")
72
- return "success"
73
- ```
74
-
75
- ### Tables
76
- | Column 1 | Column 2 | Column 3 |
77
- |----------|----------|----------|
78
- | Cell 1 | Cell 2 | Cell 3 |
79
- | Data A | Data B | Data C |
80
-
81
- ### Blockquotes
82
- > This is a blockquote with some **important** information.
83
- >
84
- > It can span multiple lines and contain *emphasis*.
85
-
86
- ### Mixed Content
87
- The document contains various **formatting** options including:
88
-
89
- - *Italicized text* for emphasis
90
- - **Bold text** for importance
91
- - `Inline code` for technical terms
92
- - Links like [this one](https://example.com)
93
-
94
- #### Final Section
95
- This concludes our comprehensive example with multiple markdown elements for testing position-based highlighting accuracy.\"\"\",
96
  "highlights": [
97
  {
98
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
@@ -114,28 +81,7 @@ This concludes our comprehensive example with multiple markdown elements for tes
114
  "content": "Position-based highlight",
115
  "category": "Position Demo",
116
  "color": "#ffeb3b"
117
- },
118
- {
119
- "position": [989, 999],
120
- "title": "Italicized",
121
- "content": "Highlighting 'Italicized'",
122
- "category": "Position Demo",
123
- "color": "#ff9800"
124
- },
125
- {
126
- "term": "formatting",
127
- "title": "formatting (Term Match)",
128
- "content": "Highlighted using term matching - will match anywhere this term appears.",
129
- "category": "Term Demo",
130
- "color": "#d0167f91"
131
- },
132
- {
133
- "position": [30, 37],
134
- "title": "regression test",
135
- "content": "Highlight across lines should not render",
136
- "category": "Position Demo",
137
- "color": "#ffeb3b"
138
- },
139
  ]
140
  }
141
 
 
59
  2. *Second item* - Another important point
60
  3. Third item with `inline code`
61
  4. Fourth item containing [a link](https://example.com)
62
+ \"\"\",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  "highlights": [
64
  {
65
  "position": [56, 61], # "quick" in "The quick brown fox", note the 2nd quick is not highlighted
 
81
  "content": "Position-based highlight",
82
  "category": "Position Demo",
83
  "color": "#ffeb3b"
84
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ]
86
  }
87
 
src/frontend/shared/EditableMarkdownRenderer.svelte CHANGED
@@ -88,7 +88,7 @@
88
  return `<span class="highlight-term"
89
  data-index="${index}"
90
  data-term="${highlight.term}"
91
- style="background-color: ${color}; cursor: pointer; padding: 2px 4px; border-radius: 3px; transition: all 0.2s;"
92
  role="button"
93
  tabindex="0"
94
  aria-label="Highlighted term: ${highlight.term}">
@@ -165,7 +165,7 @@
165
  return `<span class="highlight-position"
166
  data-index="${index}"
167
  data-text="${encodeURIComponent(targetText)}"
168
- style="background-color: ${color}; cursor: pointer; padding: 2px 4px; border-radius: 3px; transition: all 0.2s;"
169
  role="button"
170
  tabindex="0"
171
  aria-label="Highlighted text: ${targetText.replace(/"/g, '&quot;')}">
@@ -188,6 +188,10 @@
188
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
189
  }
190
 
 
 
 
 
191
  function handleTermClick(event: Event) {
192
  const target = event.target as HTMLElement;
193
  if (target.classList.contains('highlight-term') || target.classList.contains('highlight-position')) {
 
88
  return `<span class="highlight-term"
89
  data-index="${index}"
90
  data-term="${highlight.term}"
91
+ style="${getHighlightStyle(color)}"
92
  role="button"
93
  tabindex="0"
94
  aria-label="Highlighted term: ${highlight.term}">
 
165
  return `<span class="highlight-position"
166
  data-index="${index}"
167
  data-text="${encodeURIComponent(targetText)}"
168
+ style="${getHighlightStyle(color)}"
169
  role="button"
170
  tabindex="0"
171
  aria-label="Highlighted text: ${targetText.replace(/"/g, '&quot;')}">
 
188
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
189
  }
190
 
191
+ function getHighlightStyle(color: string): string {
192
+ return `background-color: ${color}; cursor: pointer; padding: 2px 2px; border-radius: 3px; transition: all 0.2s; padding-left: 4px;`;
193
+ }
194
+
195
  function handleTermClick(event: Event) {
196
  const target = event.target as HTMLElement;
197
  if (target.classList.contains('highlight-term') || target.classList.contains('highlight-position')) {
src/frontend/shared/MarkdownRenderer.svelte CHANGED
@@ -61,7 +61,7 @@
61
  return `<span class="highlight-term"
62
  data-index="${index}"
63
  data-term="${highlight.term}"
64
- style="background-color: ${color}; cursor: pointer; padding: 2px 4px; border-radius: 3px; transition: all 0.2s;"
65
  role="button"
66
  tabindex="0"
67
  aria-label="Highlighted term: ${highlight.term}">
@@ -138,7 +138,7 @@
138
  return `<span class="highlight-position"
139
  data-index="${index}"
140
  data-text="${encodeURIComponent(targetText)}"
141
- style="background-color: ${color}; cursor: pointer; padding: 2px 4px; border-radius: 3px; transition: all 0.2s;"
142
  role="button"
143
  tabindex="0"
144
  aria-label="Highlighted text: ${targetText.replace(/"/g, '&quot;')}">
@@ -161,6 +161,12 @@
161
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
162
  }
163
 
 
 
 
 
 
 
164
  function handleTermClick(event: Event) {
165
  const target = event.target as HTMLElement;
166
  if (target.classList.contains('highlight-term') || target.classList.contains('highlight-position')) {
 
61
  return `<span class="highlight-term"
62
  data-index="${index}"
63
  data-term="${highlight.term}"
64
+ style="${getHighlightStyle(color)}"
65
  role="button"
66
  tabindex="0"
67
  aria-label="Highlighted term: ${highlight.term}">
 
138
  return `<span class="highlight-position"
139
  data-index="${index}"
140
  data-text="${encodeURIComponent(targetText)}"
141
+ style="${getHighlightStyle(color)}"
142
  role="button"
143
  tabindex="0"
144
  aria-label="Highlighted text: ${targetText.replace(/"/g, '&quot;')}">
 
161
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
162
  }
163
 
164
+ // Browser implementation CSS char spacing is broken, need to adjust to excess right pad.
165
+ // https://github.com/w3c/csswg-drafts/issues/1518
166
+ function getHighlightStyle(color: string): string {
167
+ return `background-color: ${color}; cursor: pointer; padding: 2px 2px; border-radius: 3px; transition: all 0.2s; padding-left: 4px;`;
168
+ }
169
+
170
  function handleTermClick(event: Event) {
171
  const target = event.target as HTMLElement;
172
  if (target.classList.contains('highlight-term') || target.classList.contains('highlight-position')) {
src/pyproject.toml CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
8
 
9
  [project]
10
  name = "gradio_markdownlabel"
11
- version = "0.0.4"
12
  description = "Python library for easily interacting with trained machine learning models"
13
  readme = "README.md"
14
  license = "Apache-2.0"
 
8
 
9
  [project]
10
  name = "gradio_markdownlabel"
11
+ version = "0.0.5"
12
  description = "Python library for easily interacting with trained machine learning models"
13
  readme = "README.md"
14
  license = "Apache-2.0"