Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-sull authored and astrobot-houston committed Jul 22, 2022
1 parent 00fab4c commit 41f4a8f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ export interface AstroUserConfig {
* @see https://docs.astro.build/en/guides/integrations-guide/mdx/
* Default: false
*/
astroFlavoredMarkdown?: boolean;
astroFlavoredMarkdown?: boolean;
};
}

Expand Down
7 changes: 5 additions & 2 deletions packages/astro/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
vite: {},
legacy: {
astroFlavoredMarkdown: false,
}
},
};

async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<PostCSSConfigResult> {
Expand Down Expand Up @@ -214,7 +214,10 @@ export const AstroConfigSchema = z.object({
.default(ASTRO_CONFIG_DEFAULTS.vite),
legacy: z
.object({
astroFlavoredMarkdown: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown),
astroFlavoredMarkdown: z
.boolean()
.optional()
.default(ASTRO_CONFIG_DEFAULTS.legacy.astroFlavoredMarkdown),
})
.optional()
.default({}),
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/render/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export async function render(
logging,
markdown: {
...astroConfig.markdown,
isAstroFlavoredMd: astroConfig.legacy.astroFlavoredMarkdown
isAstroFlavoredMd: astroConfig.legacy.astroFlavoredMarkdown,
},
mod,
mode,
Expand Down
14 changes: 8 additions & 6 deletions packages/astro/src/runtime/server/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {

if (vnode.type) {
if (typeof vnode.type === 'function' && (vnode.type as any)['astro:renderer']) {
skipAstroJSXCheck.add(vnode.type)
skipAstroJSXCheck.add(vnode.type);
}
if (typeof vnode.type === 'function' && vnode.props['server:root']) {
const output = await vnode.type(vnode.props ?? {});
Expand Down Expand Up @@ -91,7 +91,7 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
}
if (!isVNode(child)) {
_slots.default.push(child);
return
return;
}
if ('slot' in child.props) {
_slots[child.props.slot] = [...(_slots[child.props.slot] ?? []), child];
Expand All @@ -110,10 +110,12 @@ export async function renderJSX(result: SSRResult, vnode: any): Promise<any> {
const slotPromises = [];
const slots: Record<string, any> = {};
for (const [key, value] of Object.entries(_slots)) {
slotPromises.push(renderJSX(result, value).then(output => {
if (output.toString().trim().length === 0) return;
slots[key] = () => output;
}))
slotPromises.push(
renderJSX(result, value).then((output) => {
if (output.toString().trim().length === 0) return;
slots[key] = () => output;
})
);
}
await Promise.all(slotPromises);

Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/remark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const DEFAULT_REHYPE_PLUGINS = [];
/** Shared utility for rendering markdown */
export async function renderMarkdown(
content: string,
opts: MarkdownRenderingOptions,
opts: MarkdownRenderingOptions
): Promise<MarkdownRenderingResult> {
let {
fileURL,
Expand Down
32 changes: 16 additions & 16 deletions packages/markdown/remark/test/autolinking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ describe('autolinking', () => {
describe('plain md', () => {
it('autolinks URLs starting with a protocol in plain text', async () => {
const { code } = await renderMarkdown(`See https://example.com for more.`, {});

chai
.expect(code.replace(/\n/g, ''))
.to.equal(`<p>See <a href="https://example.com">https://example.com</a> for more.</p>`);
});

it('autolinks URLs starting with "www." in plain text', async () => {
const { code } = await renderMarkdown(`See www.example.com for more.`, {});

chai
.expect(code.trim())
.to.equal(`<p>See <a href="http://www.example.com">www.example.com</a> for more.</p>`);
});

it('does not autolink URLs in code blocks', async () => {
const { code } = await renderMarkdown(
'See `https://example.com` or `www.example.com` for more.',
{}
);

chai
.expect(code.trim())
.to.equal(
Expand All @@ -35,67 +35,67 @@ describe('autolinking', () => {
});

describe('astro-flavored md', () => {
const renderAstroMd = text => renderMarkdown(text, { isAstroFlavoredMd: true });
const renderAstroMd = (text) => renderMarkdown(text, { isAstroFlavoredMd: true });

it('does not autolink URLs in code blocks', async () => {
const { code } = await renderAstroMd(
'See `https://example.com` or `www.example.com` for more.',
{}
);

chai
.expect(code.trim())
.to.equal(
`<p>See <code is:raw>https://example.com</code> or ` +
`<code is:raw>www.example.com</code> for more.</p>`
);
});

it('does not autolink URLs in fenced code blocks', async () => {
const { code } = await renderAstroMd(
'Example:\n```\nGo to https://example.com or www.example.com now.\n```'
);

chai
.expect(code)
.to.contain(`<pre is:raw`)
.to.contain(`Go to https://example.com or www.example.com now.`);
});

it('does not autolink URLs starting with a protocol when nested inside links', async () => {
const { code } = await renderAstroMd(
`See [http://example.com](http://example.com) or ` +
`<a test href="https://example.com">https://example.com</a>`
);

chai
.expect(code.replace(/\n/g, ''))
.to.equal(
`<p>See <a href="http://example.com">http://example.com</a> or ` +
`<a test href="https://example.com">https://example.com</a></p>`
);
});

it('does not autolink URLs starting with "www." when nested inside links', async () => {
const { code } = await renderAstroMd(
`See [www.example.com](https://www.example.com) or ` +
`<a test href="https://www.example.com">www.example.com</a>`
);

chai
.expect(code.replace(/\n/g, ''))
.to.equal(
`<p>See <a href="https://www.example.com">www.example.com</a> or ` +
`<a test href="https://www.example.com">www.example.com</a></p>`
);
});

it('does not autolink URLs when nested several layers deep inside links', async () => {
const { code } = await renderAstroMd(
`<a href="https://www.example.com">**Visit _our www.example.com or ` +
`http://localhost pages_ for more!**</a>`
);

chai
.expect(code.replace(/\n/g, ''))
.to.equal(
Expand All @@ -104,5 +104,5 @@ describe('autolinking', () => {
`</strong></a>`
);
});
})
});
});
5 changes: 1 addition & 4 deletions packages/markdown/remark/test/strictness.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ describe('strictness in Astro-flavored markdown', () => {
});

it('should allow attribute names starting with "@" after attribute names', async () => {
const { code } = await renderAstroMd(
`<button disabled @click="handleClick">Test</button>`,
{}
);
const { code } = await renderAstroMd(`<button disabled @click="handleClick">Test</button>`, {});

chai.expect(code.trim()).to.equal(`<button disabled @click="handleClick">Test</button>`);
});
Expand Down

0 comments on commit 41f4a8f

Please sign in to comment.