GithubHelp home page GithubHelp logo

Comments (8)

dolanmiu avatar dolanmiu commented on May 9, 2024

Yes you are right with clearVariables(). Could you find a class with has an implementation in clearVariables()?

Yes I think deprecating XmlUnit; and combining it into one class is a good idea.

Wow yes, I like the idea of using XmlComponent<Properties> will be much cleaner.

Regarding the JSON.parse thing, At the time it was quick and understandable to me. Will the new implantation of the formatter be easy to read? I don't mind sacrificing some efficiency for readability. Don't want to overengineer the problem.

from docx.

felipeochoa avatar felipeochoa commented on May 9, 2024

Almost there with the first part, but yes, I think it will be much easier to understand actually. Something like:

formatComponent(comp) {
  const ret = {};
  ret[comp.rootKey] = comp.root.map.forEach(subComp => {
    if (subComp instanceof XmlComponent)
      return formatComponent(comp);
    else  // Must be a string
      return comp
  });
  return ret;
}

(Or something like that -- I just wrote that quickly in the ocmment box)

from docx.

dolanmiu avatar dolanmiu commented on May 9, 2024

is it possible to have the format like the clearVariables() kind of style? I say this because then the format logic for each component can be inside the component itself, which could make it very clean. Just a thought.

Also, we should use native for-of rather than lodashes version (foreach)

from docx.

felipeochoa avatar felipeochoa commented on May 9, 2024

I like that idea! How about giving elements a .toXml method? We'd only have to implement it for XmlComponent and XmlAttributeComponent

from docx.

dolanmiu avatar dolanmiu commented on May 9, 2024

Yeah a .toXml() method is perfect. Nice and descriptive

from docx.

dolanmiu avatar dolanmiu commented on May 9, 2024

I am looking into the tests now, there is the jsonify() method which does JSON.parse/JSON.stringify

I am moving that out into a Utility class because its copied and pasted everywhere.

This got me thinking, surely we would need JSON.parse/JSON.stringify in the formatter as well then?

from docx.

dolanmiu avatar dolanmiu commented on May 9, 2024

Wow, I just saw you did this:

expect(tree).to.deep.equal({
     "w:spacing": [{_attr: {"w:before": 100}}],
});

which eliminates the need for the jsonify() method? Epic stuff

from docx.

felipeochoa avatar felipeochoa commented on May 9, 2024

Closed with #14

from docx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.