* Fix MDX html parsing errors For MDX wrap JSX parsing in a fragment before sending it of to babel for parsing and formatting. In MDX adjacent JSX tags are permitted in the root. An option sent to the babel parser omits printing the root fragment and instead just prints its children. Solves #6943 * an attempt to address JounQin's comments * use <$>...</$> instead of <>...</> * refactoring
22 lines
474 B
JavaScript
22 lines
474 B
JavaScript
"use strict";
|
|
|
|
function preprocess(ast, options) {
|
|
switch (options.parser) {
|
|
case "json":
|
|
case "json5":
|
|
case "json-stringify":
|
|
case "__js_expression":
|
|
case "__vue_expression":
|
|
return Object.assign({}, ast, {
|
|
type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
|
|
node: ast,
|
|
comments: [],
|
|
rootMarker: options.rootMarker
|
|
});
|
|
default:
|
|
return ast;
|
|
}
|
|
}
|
|
|
|
module.exports = preprocess;
|