preWrapper.js 795 B

123456789101112131415161718192021
  1. "use strict";
  2. // markdown-it plugin for wrapping <pre> ... </pre>.
  3. //
  4. // If your plugin was chained before preWrapper, you can add additional eleemnt directly.
  5. // If your plugin was chained after preWrapper, you can use these slots:
  6. // 1. <!--beforebegin-->
  7. // 2. <!--afterbegin-->
  8. // 3. <!--beforeend-->
  9. // 4. <!--afterend-->
  10. Object.defineProperty(exports, "__esModule", { value: true });
  11. exports.preWrapperPlugin = void 0;
  12. exports.preWrapperPlugin = (md) => {
  13. const fence = md.renderer.rules.fence;
  14. md.renderer.rules.fence = (...args) => {
  15. const [tokens, idx] = args;
  16. const token = tokens[idx];
  17. const rawCode = fence(...args);
  18. return `<div class="language-${token.info.trim()}">${rawCode}</div>`;
  19. };
  20. };
  21. //# sourceMappingURL=preWrapper.js.map