Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: preserve newlines in XML attributes #3430

Merged

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented Jan 6, 2023

I was able to test this via https://twigfiddle.com/s65ia4 and with my local checkout of phpdoc.

Essentially, this ensures that newlines are preserved in the XML attributes for structure.xml. Otherwise, the newline characters are lost.

Eg:

<method>
    <name>__construct</name>
    <docblock>
        <tag
            name="param"
            description="{
    Optional. Data for populating the Message object.

    @type string $name
          supply a name for this object
}"
            variable="options"
            type="array"
        />
    </docblock>
</method>

When usng SimpleXMLElement, this will be rendered without any newlines. E.g. { Optional. Data for populating the Message object. @type string $name supply a name for this object}.

By using the replace filter in twig, the result will instead be:

<method>
    <name>__construct</name>
    <docblock>
        <tag
            name="param"
            description="{&#10;    Optional. Data for populating the Message object.&#10;    @type string $name&#10;          supply a name for this object&#10;}"
            variable="options"
            type="array"
        />
    </docblock>
</method>

@jaapio
Copy link
Member

jaapio commented Jan 11, 2023

This is nice! Thanks

@jaapio jaapio merged commit 7e6028d into phpDocumentor:master Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants