@podlite/schema 0.0.65 → 0.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -383,21 +383,55 @@ const rules = {
383
383
  writer.writeRaw('</table>\n');
384
384
  return;
385
385
  }
386
+ // A cell holds a paragraph when the table is written as blocks, and a
387
+ // paragraph prints line breaks that would tear the row apart. The cell is
388
+ // rendered aside and folded onto one line.
389
+ const renderCell = cell => {
390
+ const parts = [];
391
+ const original = writer.output;
392
+ if (typeof original !== 'function')
393
+ return null;
394
+ writer.output = (str) => parts.push(str);
395
+ try {
396
+ ;
397
+ (cell.content || []).forEach(c => {
398
+ if (typeof c === 'string') {
399
+ writer.write(c.trim());
400
+ }
401
+ else {
402
+ interator([c], ctx);
403
+ }
404
+ });
405
+ }
406
+ finally {
407
+ writer.output = original;
408
+ }
409
+ return parts
410
+ .join('')
411
+ .replace(/\s*\n+\s*/g, ' ')
412
+ .trim();
413
+ };
386
414
  // render each row
387
415
  rows.forEach((row, rowIndex) => {
388
416
  const cells = (row.content || []).filter(c => c.name === 'cell');
389
417
  writer.writeRaw('|');
390
418
  cells.forEach(cell => {
391
419
  writer.writeRaw(' ');
392
- if (cell.content) {
393
- cell.content.forEach(c => {
394
- if (typeof c === 'string') {
395
- writer.write(c.trim());
396
- }
397
- else {
398
- interator([c], ctx);
399
- }
400
- });
420
+ const folded = renderCell(cell);
421
+ if (folded === null) {
422
+ if (cell.content) {
423
+ cell.content.forEach(c => {
424
+ if (typeof c === 'string') {
425
+ writer.write(c.trim());
426
+ }
427
+ else {
428
+ interator([c], ctx);
429
+ }
430
+ });
431
+ }
432
+ }
433
+ else {
434
+ writer.writeRaw(folded);
401
435
  }
402
436
  writer.writeRaw(' |');
403
437
  });