PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.25k stars 2.69k forks source link

span is an inline element, but exporting word wraps #2511

Open william-fanlei opened 11 months ago

william-fanlei commented 11 months ago

Describe the Bug

span is an inline element, but exporting word wraps

Steps to Reproduce

Please provide a code sample that reproduces the issue.


<?php
use PhpOffice\PhpWord\IOFactory;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\Html;

require __DIR__ . '/vendor/autoload.php';

$phpWord = new PhpWord();

        $section = $phpWord->addSection();

        $data = 'PHPWord is a library written in <span>pure PHP that provides</span> a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft Office Open XML (OOXML or OpenXML), OASIS Open Document Format for Office Applications (OpenDocument or ODF), and Rich Text Format (RTF)';
        Html::addHtml($section, $data, false, false);
        // 导出 Word 文档
        $objWriter = IOFactory::createWriter($phpWord);
        $objWriter->save($filePath);

### Expected Behavior

span tag don't wrap

### Current Behavior

span tag  wrap

### Context

Please fill in your environment information:

- PHP Version: 7.4
- PHPWord Version: 1.1
william-fanlei commented 11 months ago

image

oleibman commented 11 months ago

If you put <p> at the start of $data and </p> at the end, the span will be treated as inline.