@rtarnaud/ts-inky 0.0.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/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @rtarnaud/ts-inky
2
+
3
+ A modern TypeScript implementation of [Inky](https://get.foundation/emails), the templating language used to create responsive HTML emails with Foundation for Emails.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @rtarnaud/ts-inky
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import Inky from '@rtarnaud/ts-inky';
15
+
16
+ const inky = new Inky();
17
+ const html = '<container><row><columns>Put content in me!</columns></row></container>';
18
+ const output = inky.releaseTheKraken(html);
19
+ console.log(output);
20
+ ```
21
+
22
+ This will transform your Inky markup into responsive HTML tables suitable for email clients:
23
+
24
+ ```html
25
+ <table align="center" class="container">
26
+ <tbody>
27
+ <tr>
28
+ <td>
29
+ <table class="row">
30
+ <tbody>
31
+ <tr>
32
+ <th class="small-12 large-12 columns first last">
33
+ <table>
34
+ <tbody>
35
+ <tr>
36
+ <th>Put content in me!</th>
37
+ <th class="expander"></th>
38
+ </tr>
39
+ </tbody>
40
+ </table>
41
+ </th>
42
+ </tr>
43
+ </tbody>
44
+ </table>
45
+ </td>
46
+ </tr>
47
+ </tbody>
48
+ </table>
49
+ ```
50
+
51
+ ## Features
52
+
53
+ - 🚀 Modern TypeScript implementation with full type safety
54
+ - 📧 Full Inky component support
55
+ - 🎨 Responsive email templates optimized for all email clients
56
+ - ⚡ Fast and efficient parsing using Cheerio
57
+ - 🛠️ Type-safe API with comprehensive TypeScript definitions
58
+ - ✅ Extensively tested with Jest
59
+
60
+ ## Configuration
61
+
62
+ You can customize the behavior by passing options to the Inky constructor:
63
+
64
+ ```typescript
65
+ const inky = new Inky({
66
+ columnCount: 12, // Number of columns in the grid (default: 12)
67
+ components: { // Optional: Custom component tag names
68
+ button: 'my-button',
69
+ row: 'my-row',
70
+ // ... other component overrides
71
+ },
72
+ cheerio: {} // Optional: Custom Cheerio options
73
+ });
74
+ ```
75
+
76
+ All options are optional. The default configuration uses 12 columns and standard Inky component names (`button`, `row`, `columns`, `container`, `callout`, `menu`, `spacer`, `wrapper`, `center`, `block-grid`, `h-line`, `item`).
77
+
78
+ ## Components
79
+
80
+ Supported Inky components:
81
+
82
+ - `<container>` - Creates a responsive container (max-width: 580px)
83
+ - `<row>` - Creates a row for columns
84
+ - `<columns>` - Creates responsive columns (supports `small`, `large` attributes)
85
+ - `<button>` - Creates responsive buttons with proper email styling
86
+ - `<menu>` - Creates horizontal menus for navigation
87
+ - `<menu-item>` - Individual menu items
88
+ - `<callout>` - Creates callout panels for highlighting content
89
+ - `<spacer>` - Adds vertical spacing (supports `size`, `size-sm`, `size-lg` attributes)
90
+ - `<wrapper>` - Creates a wrapper element for full-width sections
91
+ - `<center>` - Centers content
92
+ - `<block-grid>` - Creates block grids for image galleries
93
+ - `<h-line>` - Creates horizontal lines
94
+
95
+ ## API Reference
96
+
97
+ ### `new Inky(options?)`
98
+
99
+ Creates a new Inky instance with optional configuration.
100
+
101
+ ### `inky.releaseTheKraken(htmlString: string): string`
102
+
103
+ Transforms Inky markup into responsive HTML. Pass your HTML string containing Inky components, and it returns the compiled HTML suitable for email clients.
104
+
105
+ ## Development
106
+
107
+ ### Building
108
+
109
+ ```bash
110
+ npm run build
111
+ ```
112
+
113
+ Compiles TypeScript to JavaScript in the `dist` directory.
114
+
115
+ ### Testing
116
+
117
+ ```bash
118
+ npm test
119
+ ```
120
+
121
+ Runs the Jest test suite.
122
+
123
+ ### Formatting
124
+
125
+ ```bash
126
+ npm run format
127
+ ```
128
+
129
+ Formats code using Prettier.
130
+
131
+ ## Repository
132
+
133
+ - **GitHub**: [rtarnaud/ts-inky](https://github.com/rtarnaud/ts-inky)
134
+ - **Issues**: [Report bugs](https://github.com/rtarnaud/ts-inky/issues)
135
+
136
+ ## License
137
+
138
+ [CC0-1.0](LICENSE) - Public Domain
139
+
140
+ ## Credits
141
+
142
+ Based on the original [Inky](https://github.com/foundation/inky) project by ZURB. Reimplemented in modern TypeScript by [rtarnaud](https://github.com/rtarnaud).
@@ -0,0 +1,50 @@
1
+ export type ComponentTags = {
2
+ button: "button";
3
+ row: "row";
4
+ columns: "columns";
5
+ container: "container";
6
+ callout: "callout";
7
+ inky: "inky";
8
+ blockGrid: "block-grid";
9
+ menu: "menu";
10
+ menuItem: "item";
11
+ center: "center";
12
+ spacer: "spacer";
13
+ wrapper: "wrapper";
14
+ hLine: "h-line";
15
+ };
16
+ export type InkyOptions = {
17
+ columnCount: number;
18
+ cheerio: object;
19
+ components: Partial<ComponentTags>;
20
+ };
21
+ export default class Inky {
22
+ private _columnCount;
23
+ private _cheerioOptions;
24
+ private _components;
25
+ constructor(options?: Partial<InkyOptions>);
26
+ /**
27
+ * Awww yiss. Kickstarts the whole parser.
28
+ * Takes in HTML as a string, checks if there are any custom components.
29
+ * If there are, it replaces the nested components, traverses the DOM and replaces them with email markup.
30
+ */
31
+ releaseTheKraken(xmlString: string): string;
32
+ /**
33
+ * Normalizes void elements to self-closing format BEFORE cheerio parses them.
34
+ * This prevents cheerio from treating void elements like <img> as container elements
35
+ * that can wrap other content.
36
+ */
37
+ private _normalizeVoidElements;
38
+ /**
39
+ * Converts self-closing tags to properly closed tags for non-void HTML elements.
40
+ * For example: <td/> becomes <td></td>, <th/> becomes <th></th>
41
+ * Void elements like <br/>, <hr/>, <img/>, etc. are converted to self-closing format.
42
+ * Also converts improperly paired void elements like <img></img> or <img> to <img />.
43
+ */
44
+ private _convertSelfClosingTags;
45
+ private _extractRaws;
46
+ private _reInjectRaws;
47
+ private _componentFactory;
48
+ private _makeColumn;
49
+ }
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,QAAQ,CAAC;IACjB,GAAG,EAAE,KAAK,CAAC;IACX,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACpC,CAAC;AAmCF,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,WAAW,CAAyB;gBAEhC,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM;IA+B9C;;;;OAIG;IACI,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAwClD;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IA2D/B,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,iBAAiB;IAkRzB,OAAO,CAAC,WAAW;CA4DpB"}
package/dist/index.js ADDED
@@ -0,0 +1,400 @@
1
+ import assert from "node:assert";
2
+ import { format } from "node:util";
3
+ import * as cheerio from "cheerio";
4
+ import { Document, Text, CDATA, Comment } from "domhandler";
5
+ const ignoredAttributes = [
6
+ "class",
7
+ "id",
8
+ "href",
9
+ "size",
10
+ "size-sm",
11
+ "size-lg",
12
+ "large",
13
+ "no-expander",
14
+ "small",
15
+ "target",
16
+ ];
17
+ // Grabs all attributes from an element and returns them as a string
18
+ // to be put back into outputted table elements
19
+ function getAttrs(el, $) {
20
+ let result = "";
21
+ const attrs = $(el).attr();
22
+ if (!attrs)
23
+ return result;
24
+ for (const [key, value] of Object.entries(attrs)) {
25
+ if (!ignoredAttributes.includes(key)) {
26
+ result += " " + key + "=" + '"' + value + '"';
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+ export default class Inky {
32
+ constructor(options = {}) {
33
+ // Default to 12 columns
34
+ // Column count for grid
35
+ this._columnCount = options.columnCount || 12;
36
+ // Cheerio options
37
+ this._cheerioOptions = Object.assign({}, options.cheerio || {});
38
+ // this._cheerioOptions.xml = { decodeEntities: false };
39
+ // HTML tags for custom components
40
+ this._components = Object.assign({
41
+ button: "button",
42
+ row: "row",
43
+ columns: "columns",
44
+ container: "container",
45
+ callout: "callout",
46
+ inky: "inky",
47
+ blockGrid: "block-grid",
48
+ menu: "menu",
49
+ menuItem: "item",
50
+ center: "center",
51
+ spacer: "spacer",
52
+ wrapper: "wrapper",
53
+ hLine: "h-line",
54
+ }, options.components || {});
55
+ }
56
+ /**
57
+ * Awww yiss. Kickstarts the whole parser.
58
+ * Takes in HTML as a string, checks if there are any custom components.
59
+ * If there are, it replaces the nested components, traverses the DOM and replaces them with email markup.
60
+ */
61
+ releaseTheKraken(xmlString) {
62
+ // This large compound selector looks for any custom tag loaded into Inky
63
+ // <center> is an exception: the selector is center:not([data-parsed])
64
+ // Otherwise the parser gets caught in an infinite loop where it continually tries to process the same <center> tags
65
+ let [text, raws] = this._extractRaws(xmlString);
66
+ // Normalize void elements to self-closing BEFORE cheerio parses them
67
+ // This prevents cheerio from treating them as container elements
68
+ text = this._normalizeVoidElements(text);
69
+ const $ = cheerio.load(text, this._cheerioOptions);
70
+ const tags = Object.values(this._components)
71
+ .map((tag) => {
72
+ if (tag == "center") {
73
+ return tag + ":not([data-parsed])";
74
+ }
75
+ return tag;
76
+ })
77
+ .join(", ");
78
+ // Because the structure of the DOM constantly shifts, we carefully go through each custom tag one at a time, until there are no more custom tags to parse
79
+ while ($(tags).length > 0) {
80
+ const elem = $(tags).eq(0);
81
+ const newHtml = this._componentFactory(elem, $);
82
+ elem.replaceWith(newHtml);
83
+ }
84
+ // Remove data-parsed attributes created for <center>
85
+ $("[data-parsed]").removeAttr("data-parsed");
86
+ text = $.html();
87
+ // Convert self-closing tags to properly closed tags for non-void elements
88
+ // This is needed because cheerio in XML mode outputs self-closing tags
89
+ text = this._convertSelfClosingTags(text);
90
+ return this._reInjectRaws(text, raws);
91
+ }
92
+ /**
93
+ * Normalizes void elements to self-closing format BEFORE cheerio parses them.
94
+ * This prevents cheerio from treating void elements like <img> as container elements
95
+ * that can wrap other content.
96
+ */
97
+ _normalizeVoidElements(html) {
98
+ // Convert non-self-closing void elements to self-closing format
99
+ // Match: <tagname [attributes]> but not <tagname [attributes] /> or <tagname/>
100
+ return html.replace(/<(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)(\s[^>]*?)>(?!\s*<\/\1)/gi, (match, tagName, attrs) => {
101
+ // Check if it already ends with / (meaning it's already self-closing like <img ... />)
102
+ if (attrs && attrs.trim().endsWith("/")) {
103
+ return match; // Already self-closing
104
+ }
105
+ return `<${tagName}${attrs || ""} />`;
106
+ });
107
+ }
108
+ /**
109
+ * Converts self-closing tags to properly closed tags for non-void HTML elements.
110
+ * For example: <td/> becomes <td></td>, <th/> becomes <th></th>
111
+ * Void elements like <br/>, <hr/>, <img/>, etc. are converted to self-closing format.
112
+ * Also converts improperly paired void elements like <img></img> or <img> to <img />.
113
+ */
114
+ _convertSelfClosingTags(html) {
115
+ // HTML void elements that should remain self-closing
116
+ const voidElements = [
117
+ "area",
118
+ "base",
119
+ "br",
120
+ "col",
121
+ "embed",
122
+ "hr",
123
+ "img",
124
+ "input",
125
+ "link",
126
+ "meta",
127
+ "param",
128
+ "source",
129
+ "track",
130
+ "wbr",
131
+ ];
132
+ // First, convert improperly closed void elements like <img ...></img> to self-closing <img ... />
133
+ // This handles cases where cheerio outputs paired tags for void elements
134
+ // Match: <tagname [attributes]></tagname> with optional whitespace between tags
135
+ html = html.replace(/<(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)(\s[^>]*)?\s*>\s*<\/\1\s*>/gi, (match, tagName, attrs) => {
136
+ return `<${tagName}${attrs || ""} />`;
137
+ });
138
+ // Convert non-self-closing void elements to self-closing format
139
+ // Match: <tagname [attributes]> that doesn't end with />
140
+ // We need to match <img attrs> but not <img attrs/> or <img attrs />
141
+ html = html.replace(/<(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)(\s[^>]*?)>(?!\s*<\/\1)/gi, (match, tagName, attrs) => {
142
+ // Check if it already ends with /
143
+ if (attrs && attrs.trim().endsWith("/")) {
144
+ return match; // Already self-closing
145
+ }
146
+ return `<${tagName}${attrs || ""} />`;
147
+ });
148
+ // Match self-closing tags like <tagname ... /> or <tagname/>
149
+ // Capture the tag name and any attributes
150
+ return html.replace(/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+[^>]*)?)\s*\/>/g, (match, tagName, attrs) => {
151
+ const lowerTagName = tagName.toLowerCase();
152
+ if (voidElements.includes(lowerTagName)) {
153
+ // Keep void elements as self-closing
154
+ return match;
155
+ }
156
+ // Convert to properly closed tag
157
+ return `<${tagName}${attrs || ""}></${tagName}>`;
158
+ });
159
+ }
160
+ _extractRaws(text) {
161
+ const raws = [];
162
+ let i = 0;
163
+ let raw;
164
+ let str = text;
165
+ const regex = /\< *raw *\>(.*?)\<\/ *raw *\>/i;
166
+ while ((raw = str.match(regex))) {
167
+ raws[i] = raw[1];
168
+ str = str.replace(regex, "###RAW" + i + "###");
169
+ ++i;
170
+ }
171
+ return [str, raws];
172
+ }
173
+ _reInjectRaws(text, raws) {
174
+ let str = text;
175
+ for (let i = 0; i < raws.length; ++i) {
176
+ str = str.replace("###RAW" + i + "###", raws[i]);
177
+ }
178
+ return str;
179
+ }
180
+ _componentFactory(element, $) {
181
+ let inner = element.html();
182
+ const attrs = getAttrs(element, $);
183
+ assert.ok(!(element[0] instanceof Document), "Element must not be a Document");
184
+ assert.ok(!(element[0] instanceof CDATA), "Element must not be a CDATA node");
185
+ assert.ok(!(element[0] instanceof Text), "Element must not be a Text node");
186
+ assert.ok(!(element[0] instanceof Comment), "Element must not be a Comment node");
187
+ const node = element[0];
188
+ if (!("name" in node)) {
189
+ throw new Error("Element must have a name property");
190
+ }
191
+ switch (node.name) {
192
+ // <hr>
193
+ case this._components.hLine: {
194
+ let classes = ["h-line"];
195
+ if (element.attr("class")) {
196
+ classes = classes.concat(element.attr("class").split(" "));
197
+ }
198
+ return format('<table class="%s"><tr><th>&nbsp;</th></tr></table>', classes.join(" "));
199
+ }
200
+ // <column>
201
+ case this._components.columns:
202
+ return this._makeColumn(element, $);
203
+ // <row>
204
+ case this._components.row: {
205
+ let classes = ["row"];
206
+ if (element.attr("class")) {
207
+ classes = classes.concat(element.attr("class").split(" "));
208
+ }
209
+ return format('<table %s class="%s"><tbody><tr>%s</tr></tbody></table>', attrs, classes.join(" "), inner);
210
+ }
211
+ // <button>
212
+ case this._components.button: {
213
+ let expander = "";
214
+ // Prepare optional target attribute for the <a> element
215
+ let target = "";
216
+ if (element.attr("target")) {
217
+ target = " target=" + element.attr("target");
218
+ }
219
+ // If we have the href attribute we can create an anchor for the inner of the button;
220
+ if (element.attr("href")) {
221
+ inner = format('<a %s href="%s"%s>%s</a>', attrs, element.attr("href"), target, inner);
222
+ }
223
+ // If the button is expanded, it needs a <center> tag around the content
224
+ if (element.hasClass("expand") || element.hasClass("expanded")) {
225
+ inner = format("<center>%s</center>", inner);
226
+ expander = '\n<td class="expander"></td>';
227
+ }
228
+ // The .button class is always there, along with any others on the <button> element
229
+ let classes = ["button"];
230
+ if (element.attr("class")) {
231
+ classes = classes.concat(element.attr("class").split(" "));
232
+ }
233
+ return format('<table class="%s"><tbody><tr><td><table><tbody><tr><td>%s</td></tr></tbody></table></td>%s</tr></tbody></table>', classes.join(" "), inner, expander);
234
+ }
235
+ // <container>
236
+ case this._components.container: {
237
+ let classes = ["container"];
238
+ if (element.attr("class")) {
239
+ classes = classes.concat(element.attr("class").split(" "));
240
+ }
241
+ return format('<table %s align="center" class="%s"><tbody><tr><td>%s</td></tr></tbody></table>', attrs, classes.join(" "), inner);
242
+ }
243
+ // <inky>
244
+ case this._components.inky:
245
+ return '<tr><td><img src="https://raw.githubusercontent.com/arvida/emoji-cheat-sheet.com/master/public/graphics/emojis/octopus.png" /></tr></td>';
246
+ // <block-grid>
247
+ case this._components.blockGrid: {
248
+ let classes = ["block-grid", "up-" + element.attr("up")];
249
+ if (element.attr("class")) {
250
+ classes = classes.concat(element.attr("class").split(" "));
251
+ }
252
+ return format('<table class="%s"><tbody><tr>%s</tr></tbody></table>', classes.join(" "), inner);
253
+ }
254
+ // <menu>
255
+ case this._components.menu: {
256
+ let classes = ["menu"];
257
+ if (element.attr("class")) {
258
+ classes = classes.concat(element.attr("class").split(" "));
259
+ }
260
+ return format('<table %s class="%s"><tbody><tr><td><table><tbody><tr>%s</tr></tbody></table></td></tr></tbody></table>', attrs, classes.join(" "), inner);
261
+ }
262
+ // <item>
263
+ case this._components.menuItem: {
264
+ // Prepare optional target attribute for the <a> element
265
+ let target = "";
266
+ if (element.attr("target")) {
267
+ target = " target=" + element.attr("target");
268
+ }
269
+ let classes = ["menu-item"];
270
+ if (element.attr("class")) {
271
+ classes = classes.concat(element.attr("class").split(" "));
272
+ }
273
+ return format('<th %s class="%s"><a href="%s"%s>%s</a></th>', attrs, classes.join(" "), element.attr("href"), target, inner);
274
+ }
275
+ // <center>
276
+ case this._components.center: {
277
+ if (element.children().length > 0) {
278
+ element.children().each(function () {
279
+ $(this).attr("align", "center");
280
+ $(this).addClass("float-center");
281
+ });
282
+ element.find("item, .menu-item").addClass("float-center");
283
+ }
284
+ element.attr("data-parsed", "");
285
+ // Return the full element including the <center> wrapper
286
+ return $.html(element);
287
+ }
288
+ // <callout>
289
+ case this._components.callout: {
290
+ let classes = ["callout-inner"];
291
+ if (element.attr("class")) {
292
+ classes = classes.concat(element.attr("class").split(" "));
293
+ }
294
+ return format('<table %s class="callout"><tbody><tr><th class="%s">%s</th><th class="expander"></th></tr></tbody></table>', attrs, classes.join(" "), inner);
295
+ }
296
+ // <spacer>
297
+ case this._components.spacer: {
298
+ let classes = ["spacer"];
299
+ let size;
300
+ let html = "";
301
+ if (element.attr("class")) {
302
+ classes = classes.concat(element.attr("class").split(" "));
303
+ }
304
+ if (element.attr("size-sm") || element.attr("size-lg")) {
305
+ if (element.attr("size-sm")) {
306
+ size = element.attr("size-sm");
307
+ html += format('<table %s class="%s hide-for-large"><tbody><tr><td height="' +
308
+ size +
309
+ '" style="font-size:' +
310
+ size +
311
+ "px;line-height:" +
312
+ size +
313
+ 'px;">&nbsp;</td></tr></tbody></table>', attrs);
314
+ }
315
+ if (element.attr("size-lg")) {
316
+ size = element.attr("size-lg");
317
+ html += format('<table %s class="%s show-for-large"><tbody><tr><td height="' +
318
+ size +
319
+ '" style="font-size:' +
320
+ size +
321
+ "px;line-height:" +
322
+ size +
323
+ 'px;">&nbsp;</td></tr></tbody></table>', attrs);
324
+ }
325
+ }
326
+ else {
327
+ size = element.attr("size") || 16;
328
+ html += format('<table %s class="%s"><tbody><tr><td height="' +
329
+ size +
330
+ '" style="font-size:' +
331
+ size +
332
+ "px;line-height:" +
333
+ size +
334
+ 'px;">&nbsp;</td></tr></tbody></table>', attrs);
335
+ }
336
+ if (element.attr("size-sm") && element.attr("size-lg")) {
337
+ return format(html, classes.join(" "), classes.join(" "), inner);
338
+ }
339
+ return format(html, classes.join(" "), inner);
340
+ }
341
+ // <wrapper>
342
+ case this._components.wrapper: {
343
+ let classes = ["wrapper"];
344
+ if (element.attr("class")) {
345
+ classes = classes.concat(element.attr("class").split(" "));
346
+ }
347
+ return format('<table %s class="%s" align="center"><tbody><tr><td class="wrapper-inner">%s</td></tr></tbody></table>', attrs, classes.join(" "), inner);
348
+ }
349
+ default:
350
+ // If it's not a custom component, return it as-is
351
+ return format("<tr><td>%s</td></tr>", element.html(element));
352
+ }
353
+ }
354
+ _makeColumn(col, $) {
355
+ let output = "";
356
+ const inner = col.html();
357
+ let classes = [];
358
+ let expander = "";
359
+ const attrs = getAttrs(col, $);
360
+ // Add 1 to include current column
361
+ const colCount = col.siblings(this._components.columns).length + 1;
362
+ // Inherit classes from the <column> tag
363
+ const classAttr = col.attr("class");
364
+ if (classAttr) {
365
+ classes = classes.concat(classAttr.split(" "));
366
+ }
367
+ // Check for sizes. If no attribute is provided, default to small-12. Divide evenly for large columns
368
+ const smallSize = col.attr("small") || this._columnCount;
369
+ const largeSize = col.attr("large") ||
370
+ col.attr("small") ||
371
+ Math.floor(this._columnCount / colCount);
372
+ const noExpander = col.attr("no-expander");
373
+ classes.push(format("small-%s", smallSize));
374
+ classes.push(format("large-%s", largeSize));
375
+ // Add the basic "columns" class also
376
+ classes.push("columns");
377
+ // Determine if it's the first or last column, or both
378
+ // Check for both unconverted <columns> tags and converted <th class="...columns..."> elements
379
+ const prevColumns = col.prevAll(this._components.columns).length +
380
+ col.prevAll("th.columns").length;
381
+ const nextColumns = col.nextAll(this._components.columns).length +
382
+ col.nextAll("th.columns").length;
383
+ if (!prevColumns)
384
+ classes.push("first");
385
+ if (!nextColumns)
386
+ classes.push("last");
387
+ // If the column contains a nested row, the .expander class should not be used
388
+ // The == on the first check is because we're comparing a string pulled from $.attr() to a number
389
+ if (largeSize == this._columnCount &&
390
+ col.find(".row, row").length === 0 &&
391
+ (noExpander == undefined || noExpander == "false")) {
392
+ expander = '\n<th class="expander"></th>';
393
+ }
394
+ // Final HTML output
395
+ output =
396
+ '<th class="%s" %s><table><tbody><tr><th>%s</th>%s</tr></tbody></table></th>';
397
+ return format(output, classes.join(" "), attrs, inner, expander);
398
+ }
399
+ }
400
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EA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C;QAC5C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;QAE5C,qCAAqC;QACrC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAExB,sDAAsD;QACtD,8FAA8F;QAC9F,MAAM,WAAW,GACf,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM;YAC5C,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;QACnC,MAAM,WAAW,GACf,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM;YAC5C,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEvC,8EAA8E;QAC9E,iGAAiG;QACjG,IACE,SAAS,IAAI,IAAI,CAAC,YAAY;YAC9B,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC;YAClC,CAAC,UAAU,IAAI,SAAS,IAAI,UAAU,IAAI,OAAO,CAAC,EAClD,CAAC;YACD,QAAQ,GAAG,8BAA8B,CAAC;QAC5C,CAAC;QAED,oBAAoB;QACpB,MAAM;YACJ,6EAA6E,CAAC;QAEhF,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnE,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@rtarnaud/ts-inky",
3
+ "version": "0.0.7",
4
+ "description": "A modern Inky (https://get.foundation/emails) update in TypeScript",
5
+ "keywords": [
6
+ "Inky",
7
+ "email",
8
+ "template",
9
+ "parser",
10
+ "foundation",
11
+ "typescript"
12
+ ],
13
+ "license": "CC0-1.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/rtarnaud/ts-inky.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/rtarnaud/ts-inky/issues"
20
+ },
21
+ "homepage": "https://github.com/rtarnaud/ts-inky#readme",
22
+ "type": "module",
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "test": "jest",
31
+ "format": "prettier --write index.ts test/**/*.ts",
32
+ "prepublishOnly": "npm run build"
33
+ },
34
+ "devDependencies": {
35
+ "@types/jest": "^29.5.14",
36
+ "@types/node": "^25.0.2",
37
+ "jest": "^29.7.0",
38
+ "prettier": "3.7.4",
39
+ "ts-jest": "^29.2.5",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "dependencies": {
43
+ "cheerio": "^1.1.2",
44
+ "domhandler": "^5.0.3"
45
+ }
46
+ }