hoist.js 711 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.hoistPlugin = void 0;
  4. // hoist <script> and <style> tags out of the returned html
  5. // so that they can be placed outside as SFC blocks.
  6. exports.hoistPlugin = (md) => {
  7. const RE = /^<(script|style)(?=(\s|>|$))/i;
  8. md.renderer.rules.html_block = (tokens, idx) => {
  9. const content = tokens[idx].content;
  10. const data = md.__data;
  11. const hoistedTags = data.hoistedTags || (data.hoistedTags = []);
  12. if (RE.test(content.trim())) {
  13. hoistedTags.push(content);
  14. return '';
  15. }
  16. else {
  17. return content;
  18. }
  19. };
  20. };
  21. //# sourceMappingURL=hoist.js.map