macmillanpublishers / htmlmaker_js

Repo for testing and finalizing htmlmaker javascript implementation
0 stars 1 forks source link

Add support for tables #28

Open nelliemckesson opened 7 years ago

nelliemckesson commented 7 years ago

Tables are currently dropped entirely.

In this file: https://github.com/macmillanpublishers/htmlmaker_js/blob/master/lib/convert.js

add handling to convert table objects to HTML table elements, looping through the JSON children to create tr, td, and p elements accordingly. Preserve the style name on p elements as a class name. If there's a way to use the existing paragraph conversion function on paragraph objects [convertDocxParagraph], that would probably be best.

You may want to return the JSON so you can see what you're working with: https://github.com/macmillanpublishers/htmlmaker_js/blob/master/lib/main.js#L18

nelliemckesson commented 7 years ago

I think this only needs to be fixed for the first script in this repo (the one invoked with the "htmlmaker" command), at least for now. I can supply you with a sample file that uses our styles and has a table. Roughly, what you'll want to do is:

Desired output would look like this (note that paragraph/character styles are being preserved from the Word styles used in the source):

<table>
  <tr>
    <td>
      <p class="TableColumnHeadtch"><span class="spanboldfacecharactersbf">CEO’s DIWS Score</span></p>
    </td>
    <td>
      <p class="TableColumnHeadtch"><span class="spanboldfacecharactersbf">Annual Profit (in million $)</span></p>
    </td>
  </tr>
  ...etc...
</table>

There's already a function for getting paragraph text that wraps it in the p element and preserves spans and class name (function is called convertDocxParagraph), so ideally you could reuse that when you get to the actual paragraph text within the td objects, or some part of it.

MacmillanWorkflows commented 7 years ago

➤ erica.warren commented:

Matthew Retzer moved this from the backlog into the ss start project. Still relevant?