fabianmoronzirfas
3/12/2014 - 3:55 PM

build-html-syles.jsx

(function(thisObj) {
  var parstyles = [{
      "name": "p",
      appliedFont: "Museo Slab\t300"
    }, {
      "name": "h1"
    }, {
      "name": "h2"
    }, {
      "name": "h3"
    }, {
      "name": "h4"
    }, {
      "name": "h5"
    }, {
      "name": "h6"
    }, {
      "name": "quote"
    }
  ];

  var charstyles = [{
      "name": "em"
    }, {
      "name": "bold"
    }, {
      "name": "link"
    }
  ];
  var doc = app.activeDocument;
  var prevp = null;
  for (var i = 0; i < parstyles.length; i++) {
    var pexists = doc.paragraphStyles.itemByName(parstyles[i].name);
    if(pexists !==null){
      pexists = null;
      continue;
    }
    var p = doc.paragraphStyles.add(parstyles[i]);
    if (prevp !== null) {
      p.basedOn = prevp;
    }
    prevp = p;
  }

  for (var j = 0; j < charstyles.length; j++) {
    var cexists = doc.characterStyles.itemByName(charstyles[j].name);
    if(cexists !==null){
      cexists = null;
      continue;
    }
    var c = doc.characterStyles.add(charstyles[j]);

  }

})(this);