diff --git a/README.md b/README.md index 6a0789c..7e52be9 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Here's a list of file types supported by this utility, if you have a need for an contribute, it is easy! ```ts -// src/embedme.lib.ts#L44-L80 +// src/embedme.lib.ts#L44-L82 enum SupportedFileType { PLAIN_TEXT = 'txt', @@ -120,6 +120,8 @@ enum SupportedFileType { SQL = 'sql', HASKELL = 'hs', ARDUINO = 'ino', + JSX = 'jsx', + TSX = 'tsx', } ``` diff --git a/src/embedme.lib.ts b/src/embedme.lib.ts index cf88be3..6b838e9 100644 --- a/src/embedme.lib.ts +++ b/src/embedme.lib.ts @@ -76,6 +76,8 @@ enum SupportedFileType { SQL = 'sql', HASKELL = 'hs', ARDUINO = 'ino', + JSX = 'jsx', + TSX = 'tsx', } enum CommentFamily { @@ -110,6 +112,8 @@ const languageMap: Record = { SupportedFileType.JSON_5, SupportedFileType.PROTOBUF, SupportedFileType.ARDUINO, + SupportedFileType.JSX, + SupportedFileType.TSX, ], [CommentFamily.XML]: [SupportedFileType.HTML, SupportedFileType.MARKDOWN, SupportedFileType.XML], [CommentFamily.HASH]: [ diff --git a/test/fixtures/fixture-in-place.md b/test/fixtures/fixture-in-place.md index 58a9a72..9c310e3 100644 --- a/test/fixtures/fixture-in-place.md +++ b/test/fixtures/fixture-in-place.md @@ -400,6 +400,26 @@ main = putStrLn "Hello, world!" ``` +JSX + +```jsx +// snippets/sample.jsx + +console.log('Hello World'); + +``` + +TSX + +```tsx +// snippets/sample.tsx + +export function hello(): string { + return 'Hello World'; +} + +``` + ## Extension-less selection ```sh diff --git a/test/fixtures/fixture-source.md b/test/fixtures/fixture-source.md index 849ac59..4d2c500 100644 --- a/test/fixtures/fixture-source.md +++ b/test/fixtures/fixture-source.md @@ -201,6 +201,18 @@ Haskell -- snippets/sample.hs ``` +JSX + +```jsx +// snippets/sample.jsx +``` + +TSX + +```tsx +// snippets/sample.tsx +``` + ## Extension-less selection ```sh diff --git a/test/fixtures/fixture.md b/test/fixtures/fixture.md index 58a9a72..9c310e3 100644 --- a/test/fixtures/fixture.md +++ b/test/fixtures/fixture.md @@ -400,6 +400,26 @@ main = putStrLn "Hello, world!" ``` +JSX + +```jsx +// snippets/sample.jsx + +console.log('Hello World'); + +``` + +TSX + +```tsx +// snippets/sample.tsx + +export function hello(): string { + return 'Hello World'; +} + +``` + ## Extension-less selection ```sh diff --git a/test/fixtures/snippets/sample.jsx b/test/fixtures/snippets/sample.jsx new file mode 100644 index 0000000..3451e9b --- /dev/null +++ b/test/fixtures/snippets/sample.jsx @@ -0,0 +1 @@ +console.log('Hello World'); diff --git a/test/fixtures/snippets/sample.tsx b/test/fixtures/snippets/sample.tsx new file mode 100644 index 0000000..62d0b39 --- /dev/null +++ b/test/fixtures/snippets/sample.tsx @@ -0,0 +1,3 @@ +export function hello(): string { + return 'Hello World'; +} diff --git a/test/snapshots/test.ts.md b/test/snapshots/test.ts.md index 22546a6..e161ac8 100644 --- a/test/snapshots/test.ts.md +++ b/test/snapshots/test.ts.md @@ -410,6 +410,26 @@ Generated by [AVA](https://ava.li). ␊ ```␊ ␊ + JSX␊ + ␊ + ```jsx␊ + // snippets/sample.jsx␊ + ␊ + console.log('Hello World');␊ + ␊ + ```␊ + ␊ + TSX␊ + ␊ + ```tsx␊ + // snippets/sample.tsx␊ + ␊ + export function hello(): string {␊ + return 'Hello World';␊ + }␊ + ␊ + ```␊ + ␊ ## Extension-less selection␊ ␊ ```sh␊ @@ -588,23 +608,25 @@ Generated by [AVA](https://ava.li). test/fixtures/fixture-in-place.md#L375-L382 Embedded 4 lines from file snippets/sample.cmake␊ test/fixtures/fixture-in-place.md#L386-L392 Embedded 3 lines from file snippets/sample.sql␊ test/fixtures/fixture-in-place.md#L396-L401 Embedded 2 lines from file snippets/sample.hs␊ - test/fixtures/fixture-in-place.md#L405-L411 Embedded 3 lines from file snippets/sample␊ - test/fixtures/fixture-in-place.md#L415-L426 Embedded 8 lines from file snippets/sample.cs#L6-L13␊ - test/fixtures/fixture-in-place.md#L430-L437 Embedded 4 lines from file snippets/sample.ts␊ - test/fixtures/fixture-in-place.md#L443-L445 "Ignore next" comment detected, skipping code block...␊ - test/fixtures/fixture-in-place.md#L451-L453 "Ignore next" comment detected, skipping code block...␊ - test/fixtures/fixture-in-place.md#L459-L464 Embedded 4 lines from file snippets/sample.ts␊ - test/fixtures/fixture-in-place.md#L470-L475 Embedded 4 lines from file snippets/sample.json␊ - test/fixtures/fixture-in-place.md#L481-L482 Code block is empty & no preceding embedme comment, skipping...␊ - test/fixtures/fixture-in-place.md#L486-L488 Unsupported file extension [binary], supported extensions are txt, ts, js, re, scss, rust, java, cpp, c, html, xml, md, yaml, json, json5, py, bash, sh, go, objectivec, php, cs, swift, rb, kotlin, scala, cr, puml, mermaid, cmake, proto, sql, hs, ino, skipping code block␊ - test/fixtures/fixture-in-place.md#L492-L494 No code extension detected, skipping code block...␊ - test/fixtures/fixture-in-place.md#L498-L500 No comment detected in first line for block with extension ts␊ - test/fixtures/fixture-in-place.md#L504-L506 Found filename also-not-a-file in comment in first line, but file does not exist at ${cwd}/test/fixtures/also-not-a-file!␊ - test/fixtures/fixture-in-place.md#L510-L512 Found filename this-file-does-not-exist.txt in comment in first line, but file does not exist at ${cwd}/test/fixtures/this-file-does-not-exist.txt!␊ - test/fixtures/fixture-in-place.md#L516-L518 Found filename contains-codefence.md in comment in first line, but file does not exist at ${cwd}/test/fixtures/contains-codefence.md!␊ - test/fixtures/fixture-in-place.md#L522-L528 Found filename contains-codefence.md in comment in first line, but file does not exist at ${cwd}/test/fixtures/contains-codefence.md!␊ - test/fixtures/fixture-in-place.md#L532-L534 Incorrectly formatted line numbering string snippets/sample.ts#L1-2, Expecting Github formatting e.g. #L10-L20␊ - test/fixtures/fixture-in-place.md#L538-L540 Code block is empty & no preceding embedme comment, skipping...␊ + test/fixtures/fixture-in-place.md#L405-L410 Embedded 2 lines from file snippets/sample.jsx␊ + test/fixtures/fixture-in-place.md#L414-L421 Embedded 4 lines from file snippets/sample.tsx␊ + test/fixtures/fixture-in-place.md#L425-L431 Embedded 3 lines from file snippets/sample␊ + test/fixtures/fixture-in-place.md#L435-L446 Embedded 8 lines from file snippets/sample.cs#L6-L13␊ + test/fixtures/fixture-in-place.md#L450-L457 Embedded 4 lines from file snippets/sample.ts␊ + test/fixtures/fixture-in-place.md#L463-L465 "Ignore next" comment detected, skipping code block...␊ + test/fixtures/fixture-in-place.md#L471-L473 "Ignore next" comment detected, skipping code block...␊ + test/fixtures/fixture-in-place.md#L479-L484 Embedded 4 lines from file snippets/sample.ts␊ + test/fixtures/fixture-in-place.md#L490-L495 Embedded 4 lines from file snippets/sample.json␊ + test/fixtures/fixture-in-place.md#L501-L502 Code block is empty & no preceding embedme comment, skipping...␊ + test/fixtures/fixture-in-place.md#L506-L508 Unsupported file extension [binary], supported extensions are txt, ts, js, re, scss, rust, java, cpp, c, html, xml, md, yaml, json, json5, py, bash, sh, go, objectivec, php, cs, swift, rb, kotlin, scala, cr, puml, mermaid, cmake, proto, sql, hs, ino, jsx, tsx, skipping code block␊ + test/fixtures/fixture-in-place.md#L512-L514 No code extension detected, skipping code block...␊ + test/fixtures/fixture-in-place.md#L518-L520 No comment detected in first line for block with extension ts␊ + test/fixtures/fixture-in-place.md#L524-L526 Found filename also-not-a-file in comment in first line, but file does not exist at ${cwd}/test/fixtures/also-not-a-file!␊ + test/fixtures/fixture-in-place.md#L530-L532 Found filename this-file-does-not-exist.txt in comment in first line, but file does not exist at ${cwd}/test/fixtures/this-file-does-not-exist.txt!␊ + test/fixtures/fixture-in-place.md#L536-L538 Found filename contains-codefence.md in comment in first line, but file does not exist at ${cwd}/test/fixtures/contains-codefence.md!␊ + test/fixtures/fixture-in-place.md#L542-L548 Found filename contains-codefence.md in comment in first line, but file does not exist at ${cwd}/test/fixtures/contains-codefence.md!␊ + test/fixtures/fixture-in-place.md#L552-L554 Incorrectly formatted line numbering string snippets/sample.ts#L1-2, Expecting Github formatting e.g. #L10-L20␊ + test/fixtures/fixture-in-place.md#L558-L560 Code block is empty & no preceding embedme comment, skipping...␊ Writing test/fixtures/fixture-in-place.md with embedded changes.␊ ` diff --git a/test/snapshots/test.ts.snap b/test/snapshots/test.ts.snap index b54d8c5..31c3e3c 100644 Binary files a/test/snapshots/test.ts.snap and b/test/snapshots/test.ts.snap differ