underline-xform.js 819 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const BaseXform = require('../base-xform');
  2. class UnderlineXform extends BaseXform {
  3. constructor(model) {
  4. super();
  5. this.model = model;
  6. }
  7. get tag() {
  8. return 'u';
  9. }
  10. render(xmlStream, model) {
  11. model = model || this.model;
  12. if (model === true) {
  13. xmlStream.leafNode('u');
  14. } else {
  15. const attr = UnderlineXform.Attributes[model];
  16. if (attr) {
  17. xmlStream.leafNode('u', attr);
  18. }
  19. }
  20. }
  21. parseOpen(node) {
  22. if (node.name === 'u') {
  23. this.model = node.attributes.val || true;
  24. }
  25. }
  26. parseText() {}
  27. parseClose() {
  28. return false;
  29. }
  30. }
  31. UnderlineXform.Attributes = {
  32. single: {},
  33. double: {val: 'double'},
  34. singleAccounting: {val: 'singleAccounting'},
  35. doubleAccounting: {val: 'doubleAccounting'},
  36. };
  37. module.exports = UnderlineXform;