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

Contents of <pre> should not be parsed #25

Open
inoas opened this issue May 29, 2017 · 1 comment
Open

Contents of <pre> should not be parsed #25

inoas opened this issue May 29, 2017 · 1 comment

Comments

@inoas
Copy link

inoas commented May 29, 2017

I am building some Twig based Content Application Framework and when debugging <pre>'s newlines and whitespaces should be left untouched to support plain-text content type.

@inoas
Copy link
Author

inoas commented May 29, 2017

Moving from:

case 'PLAINTEXT':
    $entity->translated_body = '<pre class="plaintext">'
        . nl2br(htmlentities(
            $entity->translated_body, ENT_XML1 | ENT_NOQUOTES | ENT_SUBSTITUTE), true)
        . '</pre>';
    break;

To:

case 'PLAINTEXT':
    $entity->translated_body = htmlentities(
        $entity->translated_body, ENT_XML1 | ENT_NOQUOTES | ENT_SUBSTITUTE);
    $entity->translated_body = str_replace(' ', '&#160;', $entity->translated_body);
    $entity->translated_body = str_replace("\t", '&#9;', $entity->translated_body);
    $entity->translated_body = nl2br($entity->translated_body, true);
    $entity->translated_body = '<pre class="plaintext">' .  $entity->translated_body . '</pre>';
    break;

Resolved most of the issue but there is still the left padding injected by indent() that shifts the <pre> output to the right.

linawolf added a commit to linawolf/rst-parser that referenced this issue Jan 19, 2023
The project has many bugs that influence testing, Especially gajus/dindent#25 is causing problems.

The project does not seem well maintained.

Switch to manual whitespace removal + DOM comparing in functional test.

Deprecate option to indent files. This was never really possible as gajus was only required in dev, option was offered for production however. Projects wishing to indent files nicer can do so in post-processing HTML, using the Events
linawolf added a commit to linawolf/rst-parser that referenced this issue Jan 19, 2023
The project has many bugs that influence testing, Especially gajus/dindent#25 is causing problems.

The project does not seem well maintained.

Switch to manual whitespace removal + DOM comparing in functional test.

Deprecate option to indent files. This was never really possible as gajus was only required in dev, option was offered for production however. Projects wishing to indent files nicer can do so in post-processing HTML, using the Events
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

No branches or pull requests

1 participant