import engine from "php-parser"; import { LATEST_SUPPORTED_PHP_VERSION } from "./options.mjs"; import { resolvePhpVersion } from "./options.mjs"; function parse(text, opts) { const inMarkdown = opts && opts.parentParser === "markdown"; if (!text && inMarkdown) { return ""; } resolvePhpVersion(opts); // Todo https://github.com/glayzzle/php-parser/issues/170 text = text.replace(/\?>\n<\?/g, "?>\n___PSEUDO_INLINE_PLACEHOLDER___ { if (comment.value[comment.value.length - 1] === "\n") { comment.value = comment.value.slice(0, -1); comment.loc.end.offset = comment.loc.end.offset - 1; } }); return ast; } export default parse;