GithubHelp home page GithubHelp logo

Comments (2)

bitsgalore avatar bitsgalore commented on June 2, 2024

Note: getting tables right is tricky this way. See below HTML, which is what I got after exporting from MS Word following some cleaning up by Tidy:

<table class="MsoNormalTable c7" border="1" cellspacing="0" cellpadding="0">
    <tr>
      <td width="229" valign="top" class='c1'>
        <p class="Tablecellheading"><span lang="EN-GB" xml:lang="EN-GB">Test
        name</span></p>
      </td>

      <td width="310" valign="top" class='c2'>
        <p class="Tablecellheading"><span lang="EN-GB" xml:lang="EN-GB">True
        if</span></p>
      </td>
    </tr>

    <tr>
      <td width="229" valign="top" class='c3'>
        <p class="Tablecell"><span lang="EN-GB" xml:lang=
        "EN-GB">boxLengthIsValid</span></p>
      </td>

      <td width="310" valign="top" class='c4'>
        <p class="Tablecell"><span lang="EN-GB" xml:lang="EN-GB">Size of box contents
        equals 4 bytes</span></p>
      </td>
    </tr>

    <tr>
      <td width="229" valign="top" class='c5'>
        <p class="Tablecell"><span lang="EN-GB" xml:lang=
        "EN-GB">signatureIsValid</span></p>
      </td>

      <td width="310" valign="top" class='c6'>
        <p class="Tablecell"><span lang="EN-GB" xml:lang="EN-GB">Signature equals
        0x0d0a870a</span></p>
      </td>
    </tr>
  </table>

Pandoc does not convert it to a nicely formatted Markdown table. After some experimentation I could make the above example work after the following steps:

  1. strip all p and span subelements from each td element
  2. Wrap first row in thead element
  3. Change td elements in first row to th
  4. wrap remainder of table in tbody element

This produces something like this:

  <table class="MsoNormalTable c7" border="1" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
        <th width="229" valign="top" class='c1'>Test name</th>

        <th width="310" valign="top" class='c2'>True if</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td width="229" valign="top" class='c3'>boxLengthIsValid</td>

        <td width="310" valign="top" class='c4'>Size of box contents equals 4 bytes</td>
      </tr>

      <tr>
        <td width="229" valign="top" class='c5'>signatureIsValid</td>

        <td width="310" valign="top" class='c6'>Signature equals 0x0d0a870a</td>
      </tr>
    </tbody>
  </table>

Throwing this at Pandoc produces:

|Test name|True if|
|:--------|:------|
|boxLengthIsValid|Size of box contents equals 4 bytes|
|signatureIsValid|Signature equals 0x0d0a870a|

Which will render as:

Test name True if
boxLengthIsValid Size of box contents equals 4 bytes
signatureIsValid Signature equals 0x0d0a870a

So the trick here will be to automate the above changes throughout the document.

from jpylyzer.

bitsgalore avatar bitsgalore commented on June 2, 2024

All done, see:

https://github.com/openplanets/jpylyzer/tree/master/doc

This is now used to produce an online version of the documentation:

http://openplanets.github.io/jpylyzer/userManual.html

Export to delivery formats other than HTML needs more work ...

from jpylyzer.

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.