index.js 856 B

1234567891011121314151617181920212223242526272829303132
  1. var postcss = require('postcss');
  2. module.exports = postcss.plugin('postcss-page-break', function () {
  3. return function (root) {
  4. root.walkDecls(/^break-(inside|before|after)/, function (decl) {
  5. // do not process column|region related properties
  6. if (decl.value.search(/column|region/) >= 0) {
  7. return;
  8. }
  9. var newValue;
  10. switch (decl.value) {
  11. case 'page':
  12. newValue = 'always';
  13. break;
  14. case 'avoid-page':
  15. newValue = 'avoid';
  16. break;
  17. default:
  18. newValue = decl.value;
  19. }
  20. decl.cloneBefore({
  21. prop: 'page-' + decl.prop,
  22. value: newValue
  23. });
  24. });
  25. };
  26. });