From 2c878b60ceb7b7b536330a900b7abe0b5df81e94 Mon Sep 17 00:00:00 2001 From: Rafe Goldberg Date: Mon, 9 Sep 2024 10:38:45 -0400 Subject: [PATCH 1/3] chore(rdmd to rmdx): wrap scripts + styles in an (#954) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🧰 Changes - [x] wrap scripts + styles in an - [x] add test cases - [x] ~implement `compatabilityMode` option~ *discussed with @kellyjosephprice and we're gonna deprecate compat mode for RMDX* (8ad57ac) ## 🧬 QA & Testing Pull this branch down and try running the test suite for the RDMD→MDX conversion: ``` npm run test -- compatability.test ``` If these new tests pass, this worked! :tada: [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg [guidance]: https://readmeio.slack.com/archives/C04R9PADCS3/p1724778026094309 "View in Slack→" --- ...ability.test.ts => compatability.test.tsx} | 70 ++++++++++++++++++- processor/transform/readme-to-mdx.ts | 15 ++++ 2 files changed, 84 insertions(+), 1 deletion(-) rename __tests__/compilers/{compatability.test.ts => compatability.test.tsx} (72%) diff --git a/__tests__/compilers/compatability.test.ts b/__tests__/compilers/compatability.test.tsx similarity index 72% rename from __tests__/compilers/compatability.test.ts rename to __tests__/compilers/compatability.test.tsx index 659afc007..7ce595f3b 100644 --- a/__tests__/compilers/compatability.test.ts +++ b/__tests__/compilers/compatability.test.tsx @@ -1,5 +1,9 @@ -import { mdx } from '../../index'; +import React from 'react'; import fs from 'node:fs'; +import { vi } from 'vitest'; +import { render, screen, prettyDOM, configure } from '@testing-library/react'; + +import { mdx, compile, run } from '../../index'; import * as rdmd from '@readme/markdown-legacy'; describe('compatability with RDMD', () => { @@ -199,4 +203,68 @@ This is an image: expect(mdx(rdmd.mdast(md))).toBe(`Contact me at {user.email}\n`); }); + + describe(' wrapping', () => { + // configure({ defaultIgnore: undefined }); + + const rawStyle = ` + `; + const rawScript = ` + `; + const magicScript = `[block:html] + { + "html": "" + } + [/block] + `; + + it('should wrap raw