@zohodesk/react-cli 1.1.6 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -44,6 +44,18 @@ Now to run app
44
44
 
45
45
  # Change Logs
46
46
 
47
+ # 1.1.8
48
+
49
+ **Issue Fix**
50
+ - Docs fix for Selector Replace 'always require arguement' issue.
51
+
52
+ # 1.1.7
53
+
54
+ **Feature**
55
+ - Markdown parser feature added in docs
56
+ For more info please refer to :
57
+ [details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/MarkdownParser.md)
58
+
47
59
  # 1.1.6
48
60
 
49
61
  **Issue Fix**
@@ -0,0 +1,18 @@
1
+
2
+ ----> markdownParser <----
3
+
4
+ 1. Markdown parser allows us to write Documentation using Markdown language inside the Javascript file
5
+ 2. This will converts the snippets to HTML tag.
6
+ 3. We can implement this only inside the particular syntax which is metioned below.
7
+ 4. We can enable/disable this feature by `npm run docs --markdown_parser=true/false` default value will be `true`.
8
+ 5. Also we can enable/disable this feature by adding `enableMDParser` key inside the package.json under the `docs`.
9
+
10
+ ### syntax
11
+ ```
12
+ /* MD:START
13
+ # Hello World
14
+ MD:END */
15
+ ```
16
+
17
+ # v1.1.7 update:
18
+ * Markdown Parser feature implemented.
@@ -85,7 +85,7 @@ module.exports = isSSTest => ({
85
85
  selectorWeightConfig,
86
86
  classNameBlob: false,
87
87
  cssUniqueness,
88
- selectorReplace: null,
88
+ selectorReplace,
89
89
  cssHashSelectors,
90
90
  classNamePrefix
91
91
  })
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ const {
4
+ markdownParser
5
+ } = require('../markdownLoader'); // Replace './your-file' with the correct file path
6
+
7
+
8
+ describe('markdownParser', () => {
9
+ test('For {}(braces) case', () => {
10
+ const source = `
11
+ /* MD:START
12
+ # {Hi, This is Test Case :)}
13
+ MD:END */
14
+ `;
15
+ const expectedOutput = `
16
+ <><div class="markDown"><h1>&#123;Hi, This is Test Case :)&#125;</h1>
17
+ </div></>
18
+ `;
19
+ expect(markdownParser(source)).toEqual(expectedOutput);
20
+ });
21
+ test('For $ (dollor) case', () => {
22
+ const source = `
23
+ /* MD:START
24
+ # $Hi, This is Test Case :)
25
+ MD:END */
26
+ `;
27
+ const expectedOutput = `
28
+ <><div class="markDown"><h1>&#36;Hi, This is Test Case :)</h1>
29
+ </div></>
30
+ `;
31
+ expect(markdownParser(source)).toEqual(expectedOutput);
32
+ });
33
+ test('For All kind of Tag Cases', () => {
34
+ const source = `
35
+ /* MD:START
36
+ # Markdown File with Variety of Data
37
+
38
+ ## Text
39
+
40
+ This is a paragraph of text.
41
+
42
+ ## Headings
43
+
44
+ ### Heading 1
45
+
46
+ ### Heading 2
47
+
48
+ #### Heading 2.1
49
+
50
+ #### Heading 2.2
51
+
52
+ ## Lists
53
+
54
+ ### Unordered List
55
+
56
+ - Item 1
57
+ - Item 2
58
+ - Item 3
59
+
60
+ ### Ordered List
61
+
62
+ 1. First item
63
+ 2. Second item
64
+ 3. Third item
65
+
66
+ ## Links
67
+
68
+ Here's a link to [OpenAI's website](https://openai.com).
69
+
70
+ ## Images
71
+
72
+ ![Markdown Logo](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)
73
+
74
+ ## Tables
75
+
76
+ | Name | Age | Gender |
77
+ |-------|-----|--------|
78
+ | John | 25 | Male |
79
+ | Sarah | 30 | Female |
80
+ | Mark | 35 | Male |
81
+
82
+ MD:END */
83
+ `;
84
+ const expectedOutput = `
85
+ <><div class="markDown"><h1>Markdown File with Variety of Data</h1>
86
+ <h2>Text</h2>
87
+ <p>This is a paragraph of text.</p>
88
+ <h2>Headings</h2>
89
+ <h3>Heading 1</h3>
90
+ <h3>Heading 2</h3>
91
+ <h4>Heading 2.1</h4>
92
+ <h4>Heading 2.2</h4>
93
+ <h2>Lists</h2>
94
+ <h3>Unordered List</h3>
95
+ <ul>
96
+ <li>Item 1</li>
97
+ <li>Item 2</li>
98
+ <li>Item 3</li>
99
+ </ul>
100
+ <h3>Ordered List</h3>
101
+ <ol>
102
+ <li>First item</li>
103
+ <li>Second item</li>
104
+ <li>Third item</li>
105
+ </ol>
106
+ <h2>Links</h2>
107
+ <p>Here's a link to <a href="https://openai.com">OpenAI's website</a>.</p>
108
+ <h2>Images</h2>
109
+ <p><img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg" alt="Markdown Logo"/></p>
110
+ <h2>Tables</h2>
111
+ <table>
112
+ <thead>
113
+ <tr>
114
+ <th>Name</th>
115
+ <th>Age</th>
116
+ <th>Gender</th>
117
+ </tr>
118
+ </thead>
119
+ <tbody>
120
+ <tr>
121
+ <td>John</td>
122
+ <td>25</td>
123
+ <td>Male</td>
124
+ </tr>
125
+ <tr>
126
+ <td>Sarah</td>
127
+ <td>30</td>
128
+ <td>Female</td>
129
+ </tr>
130
+ <tr>
131
+ <td>Mark</td>
132
+ <td>35</td>
133
+ <td>Male</td>
134
+ </tr>
135
+ </tbody>
136
+ </table>
137
+ </div></>
138
+ `;
139
+ expect(markdownParser(source)).toEqual(expectedOutput);
140
+ });
141
+ test('For Source null case', () => {
142
+ expect(markdownParser(null)).toEqual('');
143
+ expect(markdownParser('')).toEqual('');
144
+ });
145
+ });
@@ -8,6 +8,8 @@ var _path = _interopRequireDefault(require("path"));
8
8
 
9
9
  var _reactLiveConvertor = require("./reactLiveConvertor");
10
10
 
11
+ var _markdownLoader = require("./markdownLoader.js");
12
+
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
14
 
13
15
  module.exports = function (source) {
@@ -24,6 +26,7 @@ module.exports = function (source) {
24
26
 
25
27
  const src = _fs.default.readFileSync(originalFilePath).toString();
26
28
 
29
+ options.docs.enableMDParser && (source = (0, _markdownLoader.markdownParser)(source));
27
30
  options.docs.enableReactLive && (source = (0, _reactLiveConvertor.reactLiveConvertor)(source, originalFilePath)); //to Enable the ReactLive Converter
28
31
 
29
32
  return `${source};${name}.source=${JSON.stringify(src)};${name}.filePath=${JSON.stringify(filePath)}`;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.markdownParser = markdownParser;
7
+
8
+ const markdownIt = require('markdown-it'); // const md = new markdownIt({ linkify: true,breaks:true });
9
+
10
+
11
+ const md = new markdownIt({
12
+ html: false,
13
+ linkify: true,
14
+ typographer: true,
15
+ breaks: true,
16
+ xhtmlOut: true
17
+ }); //const md = new markdownIt();
18
+
19
+ function markdownParser(source) {
20
+ if (!source) {
21
+ return '';
22
+ }
23
+
24
+ const startTag = '/* MD:START';
25
+ const endTag = 'MD:END */'; // Iterate through all occurrences of the tags
26
+
27
+ let startIndex = source.indexOf(startTag);
28
+
29
+ while (startIndex !== -1) {
30
+ const endIndex = source.indexOf(endTag, startIndex);
31
+
32
+ if (endIndex !== -1) {
33
+ const extractedMarkdown = source.slice(startIndex + startTag.length, endIndex);
34
+ let lines = extractedMarkdown.split('\n');
35
+ lines = lines.filter(line => line.trim() !== '');
36
+ const firstLineIndentMatch = lines[0].match(/^\s+/);
37
+ const firstLineIndent = firstLineIndentMatch ? firstLineIndentMatch[0] : '';
38
+ const modifiedStr = lines.map(line => line.replace(new RegExp(`^${firstLineIndent}`), '')).join('\n').replace(/(:--)|(--:)/g, '---');
39
+ let html = md.render(modifiedStr); //html = html.replace(/"|<hr>|<img src=(".*?")>|<br>|:--|--:|{|}|\$/g, match => {
40
+
41
+ html = html.replace(/"|{|}|\$/g, match => {
42
+ // if (match === '<hr>') {
43
+ // return '<hr/>';
44
+ // } else if (match.startsWith('<img src=')) {
45
+ // return match.replace('>', '/>');
46
+ // } else if (match === '<br>') {
47
+ // return '<br/>';
48
+ if (match === '$') {
49
+ return '&#36;';
50
+ } else if (match === '{') {
51
+ return '&#123;';
52
+ } else if (match === '}') {
53
+ return '&#125;';
54
+ } // else if (match === ':--' || match === '--:' ) {
55
+ // return '---';
56
+ // }
57
+ else if (match === '}') {
58
+ return '&#125;';
59
+ }
60
+
61
+ return match;
62
+ }); // console.log(html,"html");
63
+
64
+ source = source.replace(source.slice(startIndex, endIndex + endTag.length), '<><div class="markDown">' + html + '</div></>');
65
+ }
66
+
67
+ startIndex = source.indexOf(startTag, startIndex + 1); // console.log(source)
68
+ }
69
+
70
+ return source;
71
+ }
@@ -382,6 +382,10 @@ var _default = {
382
382
  value: true,
383
383
  cli: 'react_live'
384
384
  },
385
+ enableMDParser: {
386
+ value: true,
387
+ cli: 'markdown_parser'
388
+ },
385
389
  rtlExclude: [],
386
390
  selectorReplace: null,
387
391
  plugins: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/react-cli",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "A CLI tool for build modern web application and libraries",
5
5
  "scripts": {
6
6
  "init": "node ./lib/utils/init.js",
@@ -80,6 +80,7 @@
80
80
  "jsdom": "16.4.0",
81
81
  "loader-utils": "2.0.0",
82
82
  "lodash-webpack-plugin": "0.11.5",
83
+ "markdown-it": "^13.0.1",
83
84
  "mini-css-extract-plugin": "0.10.0",
84
85
  "nock": "13.2.9",
85
86
  "nodemailer": "6.4.11",
@@ -2,6 +2,7 @@
2
2
  <html dir="ltr">
3
3
  <head>
4
4
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
+ <link rel="stylesheet" href="./css/markdown.css">
5
6
  <link rel="stylesheet" href="./css/b.min.css">
6
7
  <style>
7
8
  body {
@@ -5,6 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="stylesheet" href="./css/component.css" />
7
7
  <link rel="stylesheet" href="/docs/css/main.css" />
8
+ <link rel="stylesheet" href="./css/markdown.css">
8
9
  </head>
9
10
  <body>
10
11
  <div id="react" class="appContainer"></div>
@@ -6,6 +6,7 @@
6
6
  <link rel="stylesheet" href="./css/component.css" />
7
7
  <link rel="stylesheet" href="./css/componentTest.css" />
8
8
  <link rel="stylesheet" href="/docs/css/main.css" />
9
+ <link rel="stylesheet" href="./css/markdown.css">
9
10
  </head>
10
11
  <body>
11
12
  <div id="react" class="ssTest appContainer"></div>
@@ -0,0 +1,202 @@
1
+ :root{
2
+ --cli-md-cli-md-base-font-family: -apple-system,system-ui,"Segoe UI",Regular,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
3
+ --cli-md-cli-md-base-colour: #d9dcde;
4
+ }
5
+
6
+ .markDown {
7
+ line-height: 1.6;
8
+ margin: 20px;
9
+ color: #333;
10
+ font-size: 16px;
11
+ }
12
+ .markDown p {
13
+ margin-bottom: 16px;
14
+ line-height:2
15
+ }
16
+
17
+ .markDown h1 {
18
+ box-sizing: border-box;
19
+ color: var(--cli-md-base-colour);
20
+ font-family: var(--cli-md-base-font-family);
21
+ font-size: 2em;
22
+ font-weight: 600;
23
+ line-height: 1.25;
24
+ margin: 24px 0 16px;
25
+ padding-bottom: .3em;
26
+ word-wrap: break-word;
27
+ border-bottom: 1px solid #eaecef
28
+ }
29
+
30
+ .markDown h2 {
31
+ font-size: 1.5em
32
+ }
33
+
34
+ .markDown h2,.markDown h3 {
35
+ box-sizing: border-box;
36
+ color: var(--cli-md-base-colour);
37
+ font-family: var(--cli-md-base-font-family);
38
+ font-weight: 600;
39
+ line-height: 1.25;
40
+ margin-bottom: 16px;
41
+ margin-top: 24px;
42
+ padding-bottom: .3em;
43
+ word-wrap: break-word;
44
+ border-bottom: 1px solid #eaecef
45
+ }
46
+
47
+ .markDown h3 {
48
+ font-size: 1.2em
49
+ }
50
+
51
+ .markDown h4 {
52
+ box-sizing: border-box;
53
+ color: var(--cli-md-base-colour);
54
+ font-family: var(--cli-md-base-font-family);
55
+ font-size: 1em;
56
+ font-weight: 600;
57
+ line-height: 1.25;
58
+ margin-bottom: 16px;
59
+ margin-top: 24px;
60
+ word-wrap: break-word
61
+ }
62
+
63
+ .markDown td,.markDown th {
64
+ border-collapse: collapse;
65
+ box-sizing: border-box;
66
+ color: var(--cli-md-base-colour);
67
+ font-family: var(--cli-md-base-font-family);
68
+ line-height: 24px;
69
+ padding: 6px 13px;
70
+ text-align: -webkit-left;
71
+ word-wrap: break-word;
72
+ border: 1px solid #dfe2e5
73
+ }
74
+
75
+ .markDown th {
76
+ font-weight: 600
77
+ }
78
+
79
+ .markDown tr {
80
+ background-color: #fff;
81
+ border-collapse: collapse;
82
+ box-sizing: border-box;
83
+ color: var(--cli-md-base-colour);
84
+ font-family: var(--cli-md-base-font-family);
85
+ line-height: 24px;
86
+ overflow-wrap: break-word;
87
+ word-wrap: break-word
88
+ }
89
+
90
+ .markDown tr :nth-child(2n) {
91
+ background-color: #f6f8fa
92
+ }
93
+
94
+ .markDown thead {
95
+ font-size: 16px;
96
+ line-height: 1.5;
97
+ word-wrap: break-word;
98
+ border-spacing: 0;
99
+ border-collapse: collapse;
100
+ box-sizing: border-box
101
+ }
102
+
103
+ .markDown table {
104
+ -webkit-border-horizontal-spacing: 0;
105
+ -webkit-border-vertical-spacing: 0;
106
+ border-collapse: collapse;
107
+ box-sizing: border-box;
108
+ color: var(--cli-md-base-colour);
109
+ display: block;
110
+ margin-top: 0;
111
+ overflow: auto;
112
+ width: -webkit-max-content;
113
+ width: -moz-max-content;
114
+ width: max-content
115
+ }
116
+
117
+ .markDown image,.markDown table {
118
+ font-family: var(--cli-md-base-font-family);
119
+ line-height: 24px;
120
+ margin-bottom: 16px;
121
+ max-width: 100%;
122
+ word-wrap: break-word
123
+ }
124
+
125
+ .markDown image {
126
+ background-color: #fff;
127
+ border-style: none;
128
+ color: #0366d6;
129
+ cursor: pointer
130
+ }
131
+
132
+ .markDown ul {
133
+ box-sizing: border-box;
134
+ color: var(--cli-md-base-colour);
135
+ font-family: var(--cli-md-base-font-family);
136
+ line-height: 24px;
137
+ margin-bottom: 16px;
138
+ margin-top: 0;
139
+ padding-left: 2em;
140
+ word-wrap: break-word
141
+ }
142
+
143
+ .markDown ul li {
144
+ list-style: initial
145
+ }
146
+
147
+ .markDown ol li,.markDown ul li {
148
+ box-sizing: border-box;
149
+ color: var(--cli-md-base-colour);
150
+ font-family: var(--cli-md-base-font-family);
151
+ line-height: 24px;
152
+ margin-top: .25em;
153
+ text-align: left;
154
+ word-wrap: break-word
155
+ }
156
+
157
+ .markDown ol li {
158
+ list-style: decimal
159
+ }
160
+
161
+ .markDown pre {
162
+ background-color: #f6f8fa;
163
+ line-height: 1.45;
164
+ margin-bottom: 16px;
165
+ margin-top: 0;
166
+ overflow: auto;
167
+ overflow-wrap: normal;
168
+ padding: 16px;
169
+ white-space: pre;
170
+ word-break: normal
171
+ }
172
+
173
+ .markDown pre,.markDown code:not(.markDown pre code) {
174
+ border-radius: 6px;
175
+ box-sizing: border-box;
176
+ color: var(--cli-md-base-colour);
177
+ font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
178
+ font-size: 85%
179
+ }
180
+
181
+ .markDown code:not(.markDown pre code) {
182
+ background-color: rgba(27,31,35,.05);
183
+ line-height: 20.4px;
184
+ margin: 0;
185
+ padding: .2em .4em;
186
+ word-wrap: break-word
187
+ }
188
+
189
+ .markDown a {
190
+ box-sizing: border-box;
191
+ color: #0366d6;
192
+ cursor: pointer;
193
+ font-family: var(--cli-md-base-font-family);
194
+ line-height: 24px;
195
+ text-decoration: none;
196
+ word-wrap: break-word
197
+ }
198
+
199
+ .markDown a :hover {
200
+ outline: 0;
201
+ text-decoration: underline
202
+ }
@@ -14,6 +14,7 @@
14
14
  <script src="./js/active-line.js"></script>
15
15
  <script src="./js/matchbrackets.js"></script>
16
16
  <link rel="stylesheet" type="text/css" href="./css/hopscotch.css">
17
+ <link rel="stylesheet" href="./css/markdown.css">
17
18
  <title>Zoho Desk - React Components</title>
18
19
  <script>
19
20