@tryghost/mg-tinynews 0.10.8-0 → 0.11.0-0

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.
Files changed (42) hide show
  1. package/README.md +112 -30
  2. package/build/index.d.ts +8 -0
  3. package/build/index.js +5 -0
  4. package/build/index.js.map +1 -0
  5. package/build/lib/ingest.d.ts +18 -0
  6. package/build/lib/ingest.js +91 -0
  7. package/build/lib/ingest.js.map +1 -0
  8. package/build/lib/json-to-html.d.ts +35 -0
  9. package/build/lib/json-to-html.js +238 -0
  10. package/build/lib/json-to-html.js.map +1 -0
  11. package/build/lib/map.d.ts +26 -0
  12. package/build/lib/map.js +209 -0
  13. package/build/lib/map.js.map +1 -0
  14. package/build/lib/process.d.ts +76 -0
  15. package/build/lib/process.js +235 -0
  16. package/build/lib/process.js.map +1 -0
  17. package/build/lib/text.d.ts +6 -0
  18. package/build/lib/text.js +60 -0
  19. package/build/lib/text.js.map +1 -0
  20. package/build/lib/types.d.ts +112 -0
  21. package/build/lib/types.js +3 -0
  22. package/build/lib/types.js.map +1 -0
  23. package/build/test/helpers.d.ts +25 -0
  24. package/build/test/helpers.js +74 -0
  25. package/build/test/helpers.js.map +1 -0
  26. package/build/test/ingest.test.d.ts +1 -0
  27. package/build/test/ingest.test.js +134 -0
  28. package/build/test/ingest.test.js.map +1 -0
  29. package/build/test/json-to-html.test.d.ts +1 -0
  30. package/build/test/json-to-html.test.js +662 -0
  31. package/build/test/json-to-html.test.js.map +1 -0
  32. package/build/test/map.test.d.ts +1 -0
  33. package/build/test/map.test.js +367 -0
  34. package/build/test/map.test.js.map +1 -0
  35. package/build/test/process.test.d.ts +1 -0
  36. package/build/test/process.test.js +261 -0
  37. package/build/test/process.test.js.map +1 -0
  38. package/package.json +24 -10
  39. package/index.js +0 -7
  40. package/lib/json-to-html.js +0 -324
  41. package/lib/mapper.js +0 -368
  42. package/lib/text.js +0 -95
package/lib/text.js DELETED
@@ -1,95 +0,0 @@
1
- const TextNode = ({node}) => {
2
- const processChild = function (child, nextChild) {
3
- let supportedPunctuation = [',', '.', '?', '!', ';', ':', '"', '“', '”', ')'];
4
- // Add a space after this list of punctuation: colon, comma, period
5
- let supportedTrailingPunctuation = ['?', '!', ';', '"', '“', '”', '('];
6
- let delimiterSpaceChar = ' ';
7
-
8
- // If the next node/child starts with one of the punctuation marks above, don't add a space
9
- if (
10
- (nextChild &&
11
- nextChild.content &&
12
- nextChild.content[0] &&
13
- supportedPunctuation.includes(nextChild.content[0])) ||
14
- (child &&
15
- child.content &&
16
- child.content.slice(-1) &&
17
- supportedTrailingPunctuation.includes(child.content.slice(-1)))
18
- ) {
19
- delimiterSpaceChar = '';
20
- }
21
-
22
- let text = `${child.content}${child.link ? '' : delimiterSpaceChar}`;
23
-
24
- if (
25
- child &&
26
- child.content &&
27
- child.content.trim().length === 0 &&
28
- nextChild &&
29
- nextChild.content &&
30
- nextChild.content.trim().length !== 0
31
- ) {
32
- text = '<br />';
33
- }
34
-
35
- if (child.style) {
36
- if (child.style.underline && !child.link) {
37
- text = `${delimiterSpaceChar}<u>${text}</u>${delimiterSpaceChar}`;
38
- }
39
- if (child.style.italic) {
40
- text = `<em>${text}</em>${delimiterSpaceChar}`;
41
- }
42
- if (child.style.bold) {
43
- text = `<strong>${text}</strong>${delimiterSpaceChar}`;
44
- }
45
- } else {
46
- text = `${text}${child.link ? '' : delimiterSpaceChar}`;
47
- }
48
-
49
- if (child.link) {
50
- text = `${delimiterSpaceChar}<a href="${child.link}">${text}</a>${delimiterSpaceChar}`;
51
- }
52
-
53
- return text;
54
- };
55
-
56
- const children = node.children
57
- .filter(function (child) {
58
- if (!child.content || child.content === 'FORMAT START' || child.content === 'FORMAT END') {
59
- return false; // skip
60
- }
61
- return true;
62
- })
63
- .map((child, i) => {
64
- let mapped = processChild(child, node.children[i + 1]);
65
- return mapped;
66
- });
67
-
68
- if (!children || children.length <= 0) {
69
- return null;
70
- }
71
-
72
- let wrapper = null;
73
-
74
- if (node.style === 'TITLE') {
75
- wrapper = `<h1>${children.join('')}</h1>`;
76
- } else if (node.style === 'SUBTITLE') {
77
- wrapper = `<h2>${children.join('')}</h2>`;
78
- } else if (node.style === 'HEADING_1') {
79
- wrapper = `<h1>${children.join('')}</h1>`;
80
- } else if (node.style === 'HEADING_2') {
81
- wrapper = `<h2>${children.join('')}</h2>`;
82
- } else if (node.style === 'HEADING_3') {
83
- wrapper = `<h3>${children.join('')}</h3>`;
84
- } else if (node.style === 'NORMAL_TEXT') {
85
- wrapper = `<p>${children.join('')}</p>`;
86
- } else if (node.style === 'FORMATTED_TEXT') {
87
- wrapper = `<pre>${children.join('')}</pre>`;
88
- } else {
89
- wrapper = `${children.join('')}`;
90
- }
91
-
92
- return wrapper;
93
- };
94
-
95
- export {TextNode};