card-wrapper.js 418 B

12345678910111213141516171819
  1. /*
  2. 把<h>标题,替换为:::分割的标题,然后可以定制化的处理h标题
  3. */
  4. module.exports = function cardWrapper(html) {
  5. const group = html
  6. .replace(/<h3/g, ':::<h3')
  7. .replace(/<h2/g, ':::<h2')
  8. .split(':::');
  9. return group
  10. .map(fragment => {
  11. if (fragment.indexOf('<h3') !== -1) {
  12. return `<div>${fragment}</div>`;
  13. }
  14. return fragment;
  15. })
  16. .join('');
  17. };