gitbrent / PptxGenJS

Create PowerPoint presentations with a powerful, concise JavaScript API.
https://gitbrent.github.io/PptxGenJS/
MIT License
2.58k stars 606 forks source link

[BUG] Inside a table cell, a text mixed with subscript/superscript renders on multiple lines instead of one #1294

Open StevePires opened 8 months ago

StevePires commented 8 months ago

Issue Category

Product Versions

Desired Behavior

Inside a table cell, inserting a text composed of multiple texts, each one should stay on the same line, for instance. For example: composing with this: "42cm" +" ³ " + " is a small cube" should be rendered on only one line: 42cm³ is a small cube

Observed Behavior

The result in the table cells are rendered on 3 lines like this:

42cm
³
 is a small cube

Other example:

1.5 liters of H
2
O is the quantity recommended to drink per day!

(note: the '2' it is rendered in 'sub' correctly, I just don't know how to render it here)

Steps to Reproduce

const pres = new pptxgen();
const slide = pres.addSlide();

dataRow = [
          {
            text: [
              { text: '42 cm' },
              { text: '3', options: { superscript: true } },
              { text: ' is a small cube' }
            ]
          },
          {
            text: [
              { text: '1.5 liters of H' },
              { text: '2', options: { subscript: true } },
              { text: 'O is the quantity recommended to drink per day!' }
            ]
          },
          { text: 'By the way, how are you doing today?' }
];

slide.addTable(dataRow, { x: 1, y: 1, rowH: 0.4, fontSize: 10 });
StevePires commented 7 months ago

UPDATE :

Not related to being in a table cell apparently, passing a pptxgen.TextProps[] to addText() with mixed 'normal' text and sub/sup makes subScript and superScript options ineffective:

Here is a snapshot of the logged object (in console) passed to addText() image

And the result in the generated PPTX (second line, the first one comes from another object): image