fix(client): stop injecting extra comments into preview (#44723)
This commit is contained in:
committed by
GitHub
parent
e97920ae9c
commit
a00788417a
@ -14,36 +14,28 @@ import {
|
||||
transformContents
|
||||
} from '../../../../../utils/polyvinyl';
|
||||
|
||||
const htmlCatch = '\n<!--fcc-->\n';
|
||||
const jsCatch = '\n;/*fcc*/\n';
|
||||
const cssCatch = '\n/*fcc*/\n';
|
||||
|
||||
const defaultTemplate = ({ source }) => {
|
||||
return `
|
||||
<body id='display-body'>
|
||||
<!-- fcc-start-source -->
|
||||
${source}
|
||||
<!-- fcc-end-source -->
|
||||
${source}
|
||||
</body>`;
|
||||
};
|
||||
|
||||
const wrapInScript = partial(
|
||||
transformContents,
|
||||
content => `${htmlCatch}<script>${content}${jsCatch}</script>`
|
||||
content => `<script>${content}</script>`
|
||||
);
|
||||
const wrapInStyle = partial(
|
||||
transformContents,
|
||||
content => `${htmlCatch}<style>${content}${cssCatch}</style>`
|
||||
content => `<style>${content}</style>`
|
||||
);
|
||||
const setExtToHTML = partial(setExt, 'html');
|
||||
const padContentWithJsCatch = partial(compileHeadTail, jsCatch);
|
||||
const padContentWithCssCatch = partial(compileHeadTail, cssCatch);
|
||||
// const padContentWithHTMLCatch = partial(compileHeadTail, htmlCatch);
|
||||
const concatHeadTail = partial(compileHeadTail, '');
|
||||
|
||||
export const jsToHtml = cond([
|
||||
[
|
||||
matchesProperty('ext', 'js'),
|
||||
flow(padContentWithJsCatch, wrapInScript, setExtToHTML)
|
||||
flow(concatHeadTail, wrapInScript, setExtToHTML)
|
||||
],
|
||||
[stubTrue, identity]
|
||||
]);
|
||||
@ -51,7 +43,7 @@ export const jsToHtml = cond([
|
||||
export const cssToHtml = cond([
|
||||
[
|
||||
matchesProperty('ext', 'css'),
|
||||
flow(padContentWithCssCatch, wrapInStyle, setExtToHTML)
|
||||
flow(concatHeadTail, wrapInStyle, setExtToHTML)
|
||||
],
|
||||
[stubTrue, identity]
|
||||
]);
|
||||
@ -96,12 +88,12 @@ A required file can not have both a src and a link: src = ${src}, link = ${link}
|
||||
const indexHtml = findIndexHtml(challengeFiles);
|
||||
|
||||
const source = challengeFiles.reduce((source, challengeFile) => {
|
||||
if (!indexHtml) return source.concat(challengeFile.contents, htmlCatch);
|
||||
if (!indexHtml) return source.concat(challengeFile.contents);
|
||||
if (
|
||||
indexHtml.importedFiles.includes(challengeFile.history[0]) ||
|
||||
wasHtmlFile(challengeFile)
|
||||
) {
|
||||
return source.concat(challengeFile.contents, htmlCatch);
|
||||
return source.concat(challengeFile.contents);
|
||||
} else {
|
||||
return source;
|
||||
}
|
||||
|
@ -105,8 +105,6 @@ async function loadPresetReact() {
|
||||
const babelTransformCode = options => code =>
|
||||
Babel.transform(code, options).code;
|
||||
|
||||
// const sourceReg =
|
||||
// /(<!-- fcc-start-source -->)([\s\S]*?)(?=<!-- fcc-end-source -->)/g;
|
||||
const NBSPReg = new RegExp(String.fromCharCode(160), 'g');
|
||||
|
||||
const testJS = matchesProperty('ext', 'js');
|
||||
|
Reference in New Issue
Block a user