react-markdown-table-ts 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -9,12 +9,20 @@ export interface MarkdownTableData {
9
9
  /**
10
10
  * The header row of the table.
11
11
  */
12
- header: string[];
12
+ header: readonly string[];
13
13
  /**
14
14
  * The body rows of the table.
15
15
  */
16
- rows: readonly string[][];
16
+ rows: readonly TableRow[];
17
17
  }
18
+ /**
19
+ * Defines the alignment options for table columns.
20
+ */
21
+ export type Alignment = 'left' | 'center' | 'right';
22
+ /**
23
+ * Defines the available Prism.js themes for syntax highlighting.
24
+ */
25
+ export type Theme = 'prism' | 'prism-okaidia' | 'prism-tomorrow' | 'prism-coy' | 'prism-dark' | 'prism-funky' | 'prism-solarizedlight';
18
26
  /**
19
27
  * Props for the MarkdownTable component.
20
28
  */
@@ -23,7 +31,7 @@ export interface MarkdownTableProps {
23
31
  * The entire table data as a two-dimensional array.
24
32
  * If `hasHeader` is true, the first row is treated as the header.
25
33
  */
26
- data?: string[][] | null;
34
+ data?: TableRow[] | null;
27
35
  /**
28
36
  * Indicates whether the first row of `data` is a header.
29
37
  * @default true
@@ -31,9 +39,9 @@ export interface MarkdownTableProps {
31
39
  hasHeader?: boolean;
32
40
  /**
33
41
  * Optional array specifying the alignment for each column.
34
- * Acceptable values are 'left', 'center', 'right', or 'none'.
42
+ * Acceptable values are 'left', 'center', or 'right'.
35
43
  */
36
- columnAlignments?: readonly ('left' | 'center' | 'right' | 'none')[];
44
+ columnAlignments?: readonly Alignment[];
37
45
  /**
38
46
  * Optional flag to provide a compact version of the table with minimal column widths.
39
47
  * When `true`, column widths are not adjusted based on content.
@@ -58,4 +66,9 @@ export interface MarkdownTableProps {
58
66
  * Optional callback function to receive the generated Markdown table string.
59
67
  */
60
68
  onTableCreate?: (markdownString: string) => void;
69
+ /**
70
+ * Optional Prism.js theme for syntax highlighting.
71
+ * @default 'prism'
72
+ */
73
+ theme?: Theme;
61
74
  }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "react-markdown-table-ts",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "dist",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "styles"
10
11
  ],
11
12
  "scripts": {
12
13
  "build": "rollup -c",
@@ -55,6 +56,7 @@
55
56
  "@testing-library/react": "^16.0.1",
56
57
  "@types/jest": "^29.5.13",
57
58
  "@types/node": "20.12.7",
59
+ "@types/prismjs": "^1.26.4",
58
60
  "@types/react": "^18.3.8",
59
61
  "@types/react-dom": "^18.3.0",
60
62
  "eslint": "^8.50.0",
@@ -390,6 +392,7 @@
390
392
  "prettier": "^3.2.5",
391
393
  "prettier-linter-helpers": "^1.0.0",
392
394
  "pretty-format": "^27.5.1",
395
+ "prismjs": "^1.29.0",
393
396
  "process-nextick-args": "^2.0.1",
394
397
  "prompts": "^2.4.2",
395
398
  "psl": "^1.9.0",
@@ -0,0 +1,40 @@
1
+ pre[class*="language-"].line-numbers {
2
+ position: relative;
3
+ padding-left: 3.8em;
4
+ counter-reset: linenumber;
5
+ }
6
+
7
+ pre[class*="language-"].line-numbers > code {
8
+ position: relative;
9
+ white-space: inherit;
10
+ }
11
+
12
+ .line-numbers .line-numbers-rows {
13
+ position: absolute;
14
+ pointer-events: none;
15
+ top: 0;
16
+ font-size: 100%;
17
+ left: -3.8em;
18
+ width: 3em; /* works for line-numbers below 1000 lines */
19
+ letter-spacing: -1px;
20
+ border-right: 1px solid #999;
21
+
22
+ -webkit-user-select: none;
23
+ -moz-user-select: none;
24
+ -ms-user-select: none;
25
+ user-select: none;
26
+
27
+ }
28
+
29
+ .line-numbers-rows > span {
30
+ display: block;
31
+ counter-increment: linenumber;
32
+ }
33
+
34
+ .line-numbers-rows > span:before {
35
+ content: counter(linenumber);
36
+ color: #999;
37
+ display: block;
38
+ padding-right: 0.8em;
39
+ text-align: right;
40
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * prism.js default theme for JavaScript, CSS and HTML
3
+ * Based on dabblet (http://dabblet.com)
4
+ * @author Lea Verou
5
+ */
6
+
7
+ code[class*="language-"],
8
+ pre[class*="language-"] {
9
+ color: black;
10
+ background: none;
11
+ text-shadow: 0 1px white;
12
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
13
+ font-size: 1em;
14
+ text-align: left;
15
+ white-space: pre;
16
+ word-spacing: normal;
17
+ word-break: normal;
18
+ word-wrap: normal;
19
+ line-height: 1.5;
20
+
21
+ -moz-tab-size: 4;
22
+ -o-tab-size: 4;
23
+ tab-size: 4;
24
+
25
+ -webkit-hyphens: none;
26
+ -moz-hyphens: none;
27
+ -ms-hyphens: none;
28
+ hyphens: none;
29
+ }
30
+
31
+ pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
32
+ code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
33
+ text-shadow: none;
34
+ background: #b3d4fc;
35
+ }
36
+
37
+ pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
38
+ code[class*="language-"]::selection, code[class*="language-"] ::selection {
39
+ text-shadow: none;
40
+ background: #b3d4fc;
41
+ }
42
+
43
+ @media print {
44
+ code[class*="language-"],
45
+ pre[class*="language-"] {
46
+ text-shadow: none;
47
+ }
48
+ }
49
+
50
+ /* Code blocks */
51
+ pre[class*="language-"] {
52
+ padding: 1em;
53
+ margin: .5em 0;
54
+ overflow: auto;
55
+ }
56
+
57
+ :not(pre) > code[class*="language-"],
58
+ pre[class*="language-"] {
59
+ background: #f5f2f0;
60
+ }
61
+
62
+ /* Inline code */
63
+ :not(pre) > code[class*="language-"] {
64
+ padding: .1em;
65
+ border-radius: .3em;
66
+ white-space: normal;
67
+ }
68
+
69
+ .token.comment,
70
+ .token.prolog,
71
+ .token.doctype,
72
+ .token.cdata {
73
+ color: slategray;
74
+ }
75
+
76
+ .token.punctuation {
77
+ color: #999;
78
+ }
79
+
80
+ .token.namespace {
81
+ opacity: .7;
82
+ }
83
+
84
+ .token.property,
85
+ .token.tag,
86
+ .token.boolean,
87
+ .token.number,
88
+ .token.constant,
89
+ .token.symbol,
90
+ .token.deleted {
91
+ color: #905;
92
+ }
93
+
94
+ .token.selector,
95
+ .token.attr-name,
96
+ .token.string,
97
+ .token.char,
98
+ .token.builtin,
99
+ .token.inserted {
100
+ color: #690;
101
+ }
102
+
103
+ .token.operator,
104
+ .token.entity,
105
+ .token.url,
106
+ .language-css .token.string,
107
+ .style .token.string {
108
+ color: #9a6e3a;
109
+ /* This background color was intended by the author of this theme. */
110
+ background: hsla(0, 0%, 100%, .5);
111
+ }
112
+
113
+ .token.atrule,
114
+ .token.attr-value,
115
+ .token.keyword {
116
+ color: #07a;
117
+ }
118
+
119
+ .token.function,
120
+ .token.class-name {
121
+ color: #DD4A68;
122
+ }
123
+
124
+ .token.regex,
125
+ .token.important,
126
+ .token.variable {
127
+ color: #e90;
128
+ }
129
+
130
+ .token.important,
131
+ .token.bold {
132
+ font-weight: bold;
133
+ }
134
+ .token.italic {
135
+ font-style: italic;
136
+ }
137
+
138
+ .token.entity {
139
+ cursor: help;
140
+ }
@@ -0,0 +1,219 @@
1
+ /**
2
+ * prism.js Coy theme for JavaScript, CoffeeScript, CSS and HTML
3
+ * Based on https://github.com/tshedor/workshop-wp-theme (Example: http://workshop.kansan.com/category/sessions/basics or http://workshop.timshedor.com/category/sessions/basics);
4
+ * @author Tim Shedor
5
+ */
6
+
7
+ code[class*="language-"],
8
+ pre[class*="language-"] {
9
+ color: black;
10
+ background: none;
11
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
12
+ font-size: 1em;
13
+ text-align: left;
14
+ white-space: pre;
15
+ word-spacing: normal;
16
+ word-break: normal;
17
+ word-wrap: normal;
18
+ line-height: 1.5;
19
+
20
+ -moz-tab-size: 4;
21
+ -o-tab-size: 4;
22
+ tab-size: 4;
23
+
24
+ -webkit-hyphens: none;
25
+ -moz-hyphens: none;
26
+ -ms-hyphens: none;
27
+ hyphens: none;
28
+ }
29
+
30
+ /* Code blocks */
31
+ pre[class*="language-"] {
32
+ position: relative;
33
+ margin: .5em 0;
34
+ overflow: visible;
35
+ padding: 1px;
36
+ }
37
+
38
+ pre[class*="language-"] > code {
39
+ position: relative;
40
+ z-index: 1;
41
+ border-left: 10px solid #358ccb;
42
+ box-shadow: -1px 0px 0px 0px #358ccb, 0px 0px 0px 1px #dfdfdf;
43
+ background-color: #fdfdfd;
44
+ background-image: linear-gradient(transparent 50%, rgba(69, 142, 209, 0.04) 50%);
45
+ background-size: 3em 3em;
46
+ background-origin: content-box;
47
+ background-attachment: local;
48
+ }
49
+
50
+ code[class*="language-"] {
51
+ max-height: inherit;
52
+ height: inherit;
53
+ padding: 0 1em;
54
+ display: block;
55
+ overflow: auto;
56
+ }
57
+
58
+ /* Margin bottom to accommodate shadow */
59
+ :not(pre) > code[class*="language-"],
60
+ pre[class*="language-"] {
61
+ background-color: #fdfdfd;
62
+ -webkit-box-sizing: border-box;
63
+ -moz-box-sizing: border-box;
64
+ box-sizing: border-box;
65
+ margin-bottom: 1em;
66
+ }
67
+
68
+ /* Inline code */
69
+ :not(pre) > code[class*="language-"] {
70
+ position: relative;
71
+ padding: .2em;
72
+ border-radius: 0.3em;
73
+ color: #c92c2c;
74
+ border: 1px solid rgba(0, 0, 0, 0.1);
75
+ display: inline;
76
+ white-space: normal;
77
+ }
78
+
79
+ pre[class*="language-"]:before,
80
+ pre[class*="language-"]:after {
81
+ content: '';
82
+ display: block;
83
+ position: absolute;
84
+ bottom: 0.75em;
85
+ left: 0.18em;
86
+ width: 40%;
87
+ height: 20%;
88
+ max-height: 13em;
89
+ box-shadow: 0px 13px 8px #979797;
90
+ -webkit-transform: rotate(-2deg);
91
+ -moz-transform: rotate(-2deg);
92
+ -ms-transform: rotate(-2deg);
93
+ -o-transform: rotate(-2deg);
94
+ transform: rotate(-2deg);
95
+ }
96
+
97
+ pre[class*="language-"]:after {
98
+ right: 0.75em;
99
+ left: auto;
100
+ -webkit-transform: rotate(2deg);
101
+ -moz-transform: rotate(2deg);
102
+ -ms-transform: rotate(2deg);
103
+ -o-transform: rotate(2deg);
104
+ transform: rotate(2deg);
105
+ }
106
+
107
+ .token.comment,
108
+ .token.block-comment,
109
+ .token.prolog,
110
+ .token.doctype,
111
+ .token.cdata {
112
+ color: #7D8B99;
113
+ }
114
+
115
+ .token.punctuation {
116
+ color: #5F6364;
117
+ }
118
+
119
+ .token.property,
120
+ .token.tag,
121
+ .token.boolean,
122
+ .token.number,
123
+ .token.function-name,
124
+ .token.constant,
125
+ .token.symbol,
126
+ .token.deleted {
127
+ color: #c92c2c;
128
+ }
129
+
130
+ .token.selector,
131
+ .token.attr-name,
132
+ .token.string,
133
+ .token.char,
134
+ .token.function,
135
+ .token.builtin,
136
+ .token.inserted {
137
+ color: #2f9c0a;
138
+ }
139
+
140
+ .token.operator,
141
+ .token.entity,
142
+ .token.url,
143
+ .token.variable {
144
+ color: #a67f59;
145
+ background: rgba(255, 255, 255, 0.5);
146
+ }
147
+
148
+ .token.atrule,
149
+ .token.attr-value,
150
+ .token.keyword,
151
+ .token.class-name {
152
+ color: #1990b8;
153
+ }
154
+
155
+ .token.regex,
156
+ .token.important {
157
+ color: #e90;
158
+ }
159
+
160
+ .language-css .token.string,
161
+ .style .token.string {
162
+ color: #a67f59;
163
+ background: rgba(255, 255, 255, 0.5);
164
+ }
165
+
166
+ .token.important {
167
+ font-weight: normal;
168
+ }
169
+
170
+ .token.bold {
171
+ font-weight: bold;
172
+ }
173
+ .token.italic {
174
+ font-style: italic;
175
+ }
176
+
177
+ .token.entity {
178
+ cursor: help;
179
+ }
180
+
181
+ .token.namespace {
182
+ opacity: .7;
183
+ }
184
+
185
+ @media screen and (max-width: 767px) {
186
+ pre[class*="language-"]:before,
187
+ pre[class*="language-"]:after {
188
+ bottom: 14px;
189
+ box-shadow: none;
190
+ }
191
+
192
+ }
193
+
194
+ /* Plugin styles: Line Numbers */
195
+ pre[class*="language-"].line-numbers.line-numbers {
196
+ padding-left: 0;
197
+ }
198
+
199
+ pre[class*="language-"].line-numbers.line-numbers code {
200
+ padding-left: 3.8em;
201
+ }
202
+
203
+ pre[class*="language-"].line-numbers.line-numbers .line-numbers-rows {
204
+ left: 0;
205
+ }
206
+
207
+ /* Plugin styles: Line Highlight */
208
+ pre[class*="language-"][data-line] {
209
+ padding-top: 0;
210
+ padding-bottom: 0;
211
+ padding-left: 0;
212
+ }
213
+ pre[data-line] code {
214
+ position: relative;
215
+ padding-left: 4em;
216
+ }
217
+ pre .line-highlight {
218
+ margin-top: 0;
219
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ * prism.js Dark theme for JavaScript, CSS and HTML
3
+ * Based on the slides of the talk “/Reg(exp){2}lained/”
4
+ * @author Lea Verou
5
+ */
6
+
7
+ code[class*="language-"],
8
+ pre[class*="language-"] {
9
+ color: white;
10
+ background: none;
11
+ text-shadow: 0 -.1em .2em black;
12
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
13
+ font-size: 1em;
14
+ text-align: left;
15
+ white-space: pre;
16
+ word-spacing: normal;
17
+ word-break: normal;
18
+ word-wrap: normal;
19
+ line-height: 1.5;
20
+
21
+ -moz-tab-size: 4;
22
+ -o-tab-size: 4;
23
+ tab-size: 4;
24
+
25
+ -webkit-hyphens: none;
26
+ -moz-hyphens: none;
27
+ -ms-hyphens: none;
28
+ hyphens: none;
29
+ }
30
+
31
+ @media print {
32
+ code[class*="language-"],
33
+ pre[class*="language-"] {
34
+ text-shadow: none;
35
+ }
36
+ }
37
+
38
+ pre[class*="language-"],
39
+ :not(pre) > code[class*="language-"] {
40
+ background: hsl(30, 20%, 25%);
41
+ }
42
+
43
+ /* Code blocks */
44
+ pre[class*="language-"] {
45
+ padding: 1em;
46
+ margin: .5em 0;
47
+ overflow: auto;
48
+ border: .3em solid hsl(30, 20%, 40%);
49
+ border-radius: .5em;
50
+ box-shadow: 1px 1px .5em black inset;
51
+ }
52
+
53
+ /* Inline code */
54
+ :not(pre) > code[class*="language-"] {
55
+ padding: .15em .2em .05em;
56
+ border-radius: .3em;
57
+ border: .13em solid hsl(30, 20%, 40%);
58
+ box-shadow: 1px 1px .3em -.1em black inset;
59
+ white-space: normal;
60
+ }
61
+
62
+ .token.comment,
63
+ .token.prolog,
64
+ .token.doctype,
65
+ .token.cdata {
66
+ color: hsl(30, 20%, 50%);
67
+ }
68
+
69
+ .token.punctuation {
70
+ opacity: .7;
71
+ }
72
+
73
+ .token.namespace {
74
+ opacity: .7;
75
+ }
76
+
77
+ .token.property,
78
+ .token.tag,
79
+ .token.boolean,
80
+ .token.number,
81
+ .token.constant,
82
+ .token.symbol {
83
+ color: hsl(350, 40%, 70%);
84
+ }
85
+
86
+ .token.selector,
87
+ .token.attr-name,
88
+ .token.string,
89
+ .token.char,
90
+ .token.builtin,
91
+ .token.inserted {
92
+ color: hsl(75, 70%, 60%);
93
+ }
94
+
95
+ .token.operator,
96
+ .token.entity,
97
+ .token.url,
98
+ .language-css .token.string,
99
+ .style .token.string,
100
+ .token.variable {
101
+ color: hsl(40, 90%, 60%);
102
+ }
103
+
104
+ .token.atrule,
105
+ .token.attr-value,
106
+ .token.keyword {
107
+ color: hsl(350, 40%, 70%);
108
+ }
109
+
110
+ .token.regex,
111
+ .token.important {
112
+ color: #e90;
113
+ }
114
+
115
+ .token.important,
116
+ .token.bold {
117
+ font-weight: bold;
118
+ }
119
+ .token.italic {
120
+ font-style: italic;
121
+ }
122
+
123
+ .token.entity {
124
+ cursor: help;
125
+ }
126
+
127
+ .token.deleted {
128
+ color: red;
129
+ }