chore: enable html on preview playground (#5105)

master
Ika 2018-09-19 09:19:18 +08:00 committed by GitHub
parent 5bcd4424fa
commit 79f4251e26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 10 deletions

View File

@ -98,7 +98,7 @@ async function run(params) {
await execa("rm", ["-rf", ".cache"]);
}
const bundleCache = new Cache(".cache/", "v6");
const bundleCache = new Cache(".cache/", "v7");
await bundleCache.load();
console.log(chalk.inverse(" Building packages "));

View File

@ -69,7 +69,7 @@ const parsers = [
},
{
input: "src/language-html/parser-parse5.js",
target: "node"
target: "universal"
},
{
input: "src/language-yaml/parser-yaml.js",

View File

@ -121,7 +121,8 @@ const options = {
value: "glimmer",
since: null,
description: "Handlebars"
}
},
{ value: "parse5", since: null, description: "HTML" }
]
},
plugins: {

View File

@ -9,10 +9,11 @@ const sharedUtil = require("./common/util-shared");
const doc = require("./doc");
const internalPlugins = [
require("./language-js"),
require("./language-css"),
require("./language-graphql"),
require("./language-handlebars"),
require("./language-html"),
require("./language-js"),
require("./language-markdown"),
require("./language-vue"),
require("./language-yaml")

View File

@ -8,11 +8,12 @@ const sources = [
"standalone.js",
"parser-babylon.js",
"parser-flow.js",
"parser-typescript.js",
"parser-postcss.js",
"parser-glimmer.js",
"parser-graphql.js",
"parser-markdown.js",
"parser-parse5.js",
"parser-postcss.js",
"parser-typescript.js",
"parser-vue.js",
"parser-yaml.js"
].map(filename =>

View File

@ -127,8 +127,8 @@ function read(filename) {
return fs.readFileSync(filename, "utf8");
}
function skipStandalone(parser) {
return new Set(["parse5"]).has(parser);
function skipStandalone(/* parser */) {
return false;
}
function mergeDefaultOptions(parserConfig) {

View File

@ -282,6 +282,25 @@ export default function(parser) {
" {{ body }}",
"</div> </div>"
].join("\n");
case "parse5":
return [
"<!DOCTYPE html>",
'<HTML CLASS="no-js mY-ClAsS">',
" <HEAD>",
' <META CHARSET="utf-8">',
" <TITLE>My tITlE</TITLE>",
' <META NAME="description" content="My CoNtEnT">',
" </HEAD>",
" <body>",
" <P>Hello world!<BR> This is HTML5 Boilerplate.</P>",
" <SCRIPT>",
" window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;",
" ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')",
" </SCRIPT>",
' <SCRIPT src="https://www.google-analytics.com/analytics.js" ASYNC DEFER></SCRIPT>',
" </body>",
"</HTML>"
].join("\n");
default:
return "";
}

View File

@ -45,6 +45,8 @@ function getMarkdownSyntax(options) {
return "jsonc";
case "glimmer":
return "hbs";
case "parse5":
return "html";
default:
return options.parser;
}

View File

@ -9,12 +9,13 @@ toolbox.precache([
// Scripts
"lib/standalone.js",
"lib/parser-babylon.js",
"lib/parser-typescript.js",
"lib/parser-postcss.js",
"lib/parser-flow.js",
"lib/parser-glimmer.js",
"lib/parser-graphql.js",
"lib/parser-markdown.js",
"lib/parser-parse5.js",
"lib/parser-postcss.js",
"lib/parser-typescript.js",
"lib/parser-vue.js",
"lib/parser-yaml.js",
"playground.js",

View File

@ -90,6 +90,12 @@ var parsers = {
get glimmer() {
importScriptOnce("lib/parser-glimmer.js");
return prettierPlugins.glimmer.parsers.glimmer;
},
// HTML
get parse5() {
importScriptOnce("lib/parser-parse5.js");
return prettierPlugins.parse5.parsers.parse5;
}
};