Giter VIP home page Giter VIP logo

emogrifier's People

Contributors

acorncom avatar adduc avatar bramley avatar chrisdeeming avatar demis-palma avatar dependabot[bot] avatar erikhansen avatar finwe avatar ionelscutelnicu avatar jakeqz avatar jjriv avatar jorrit avatar joubertredrat avatar jriboux avatar kozaktomas avatar markhalliwell avatar mistic100 avatar oliverklee avatar osbre avatar pmclain avatar renkas avatar sanderkruger avatar seldaek avatar signpostmarv avatar synchro avatar tams avatar timothyasp avatar timwolla avatar vanderlee avatar zoliszabo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emogrifier's Issues

PHP 5.5 compatibility

preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

Location: emogrifier.php on line 315

:first-child and :last-child selectors do not add CSS

There were 2 failures:

  1. Pelago\Tests\Unit\EmogrifierTest::emogrifierMatchesSelectors with data set "BODY:first-child matches first child" ('body:first-child {color: red} ', '#

    #')
    Failed asserting that '

some text

some text

some more text

' matches PCRE pattern "#

#".

/home/klee/eclipse/emogrifier/Tests/Unit/EmogrifierTest.php:370

  1. Pelago\Tests\Unit\EmogrifierTest::emogrifierMatchesSelectors with data set "BODY:last-child matches last child" ('body:last-child {color: red} ', '#

    #')
    Failed asserting that '

some text

some text

some more text

' matches PCRE pattern "#

#".

/home/klee/eclipse/emogrifier/Tests/Unit/EmogrifierTest.php:370

FAILURES!
Tests: 57, Assertions: 57, Failures: 2.

This is for the following lines in selectorDataProvider:

        'BODY:first-child matches first child'
            => array('body:first-child {' . $styleRule . '} ', '#<p class="p-1" style="' . $styleRule . '">#'),
        'BODY:first-child not matches middle child' => array('body:first-child {' . $styleRule . '} ', '#<p class="p-2">#'),
        'BODY:first-child not matches last child' => array('body:first-child {' . $styleRule . '} ', '#<p class="p-3">#'),
        'BODY:last-child not matches first child' => array('body:last-child {' . $styleRule . '} ', '#<p class="p-1">#'),
        'BODY:last-child not matches middle child' => array('body:last-child {' . $styleRule . '} ', '#<p class="p-2">#'),
        'BODY:last-child matches last child' => array('body:last-child {' . $styleRule . '} ', '#<p class="p-3" style="' . $styleRule . '">#'),

Installing as dependency of a package fails

Hi

I'm writing a package that requires the emogrifier as a dependency of the package, I get an error when trying to install my package, saying that there is no matching package for the emogrifier require.

  • oligriffiths/emails-component dev-master requires pelago/emogrifier dev-master-> no matching package found.

However if installing as a require in the root composer.json the package installs fine.

Any ideas?

oli

Supporting id attributes

Any plans on supporting IDs?
There might be some templates that actually use that

css: div#container { margin: 1em auto; }

html: <div id="container">

They can - just as classes - also be stripped then afterwards.

Bug: UTF8 issues

It looks like this lib has the same issues as InlineCss, it cannot work with some UTF8 chars:

<div id="container">
    <h1>チェック</h1>
    <p>降です。アーリーチェックインはリクエ</p>
    <p class="small">チェック'foo'</p>
</div>

Gets scrambled into

<div id="container">
    <h1 style="font-weight: bold; font-size: 2em;">&#12481;&#12455;&#12483;&#12463;</h1>
    <p style="margin-bottom: 1em; font-family: sans-serif; text-align: justify;">&#38477;&#12391;&#12377;&#12290;&#12450;&#12540;&#12522;&#12540;&#12481;&#12455;&#12483;&#12463;&#12452;&#12531;&#12399;&#12522;&#12463;&#12456;</p>
    <p class="small" style="margin-bottom:1em;font-family:sans-serif;text-align:justify;font-size:70%;">&#12481;&#12455;&#12483;&#12463;'foo'</p>
</div>

For the other lib I got i partially working again using htmlentitiesdecode.

style tags in HTML cause an Xpath invalid query error

/**
 * @test
 */
public function emogrifyAppliesCssFromStyleNodes() {
    $styleAttributeValue = 'color:#ccc;';
    $html = self::HTML5_DOCUMENT_TYPE . self::LF .
        '<html><style type="text/css">html {' . $styleAttributeValue . '}</style></html>';
    $this->subject->setHtml($html);

    $this->assertContains(
        '<html style="' . $styleAttributeValue . '">',
        $this->subject->emogrify()
    );
}

PHPUnit 3.7.29 by Sebastian Bergmann.

.........................................................E

Time: 59 ms, Memory: 3.00Mb

There was 1 error:

1) Pelago\Tests\Unit\EmogrifierTest::emogrifyAppliesCssFromStyleNodes
DOMXPath::query(): Invalid expression

Version number in documentation on the composer configuration needs to be "@dev"

I had to use "pelago/emogrifier": "@dev" in my composer.json. Otherwise I got

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package pelago/emogrifier could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

refactor of parseCssDeclarationBlock

Creating this ticket per request to not leave comments in the code:

if (!preg_match('/ *([A-Za-z-]+) *: *([^;]+) */', $declaration, $matches)) {
continue;
}
// can we remove this regex entirely and replace with an explode on :, and conditional on resulting array being 2 strings?

It seems like this regex is only verifying that we have a single css declaration, and then using the regex match for the propertyName and propertyValue. I added the note because in the back of my head I thought an explode on the colon, and then verifying the resultant array has exactly 2 elements, and then using the 1st as propertyName and second as propertyValue would be quicker than a regex.

empty <tr></tr>

Hi,

We have a problem in Outlook 2007 and 2010 with empty (the make a big line height with empty space), we can reproduce this issue here http://www.pelagodesign.com/sidecar/emogrifier/

with this css:

.zusatzleistung_desc_tr{
 display: none;
visibility: hidden;
}

and this html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    </head>
    <body>
        <table class="angebotdetails">
            <tr class="zusatzleistung_desc_tr">
                <td class="zusatzleistung_desc">Cane</td>
                <td class="zusatzleistung_amount">5,00 Euro</td>
            </tr>
        </table>
    </body>
</html>

gives after emogrify:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
        <table><tr></tr></table>
</body>
</html>

it should be:

<table>
        <tr style=" display: none;visibility: hidden;">
            <td class="zusatzleistung_desc">Cane</td>
            <td class="zusatzleistung_amount">5,00 Euro</td>
        </tr>
</table>

or remove the tr as well.

thank you!
lenny

Reorder the methods

The following order should make the class more logical to read:

  1. constructor
  2. destructor
  3. setHtml
  4. setCss
  5. emogriy
  6. other public methods

Emogrifier turns $ into %24 unexpectedly

I use merge tags in my email bulletins to customize their content, for example to show the name of the recipient, I use the string $[USER:NAME]$ and then I replace it with the name.
If I place the merge tag wrapped in a span or div, there is no inconvenience, but if the merge tag is inside an attribute, let's say an href, emogrifier turns the '$' symbol to '%24' and '[' to '%5B' respectively.
If my original html is <a href="$[LINK:EVENT]$">LINK</a> emogrifier turns it into <a href="%24%5BLINK:EVENT%5D%24">LINK</a>

Any advice to avoid this behavior?

Release pre-1.0 stable version

Because the only available version of this package is 1.0-alpha1, the only way one can install this package with Composer as part of another component is by reducing the strength of minimum-stability.

Could you please release a 0.1 version of the current state of the component, so that other libraries which depend on this component do not require the root project to reduce minimum-stability, without having to wait for 1.0?

Drop support for PHP 5.3

We should do this once PHP 5.3 has reached its end of life, i.e., probably some time around June 2014.

Add composer.json

It would be cool if you can add a composer.json to this repo so that we can install it using packagist and use composer's autoloader 😄

Clean up early returns

  • only allow early returns for guard clauses
  • check where guard clauses would make sense

Semantic versioned releases

Would it be possible to use github's release feature and semantic versioning? It would make dependencies much easier/safer in composer.

inconsistent handling of css case

Unit test:
emogrifyLowercasesAttributeNamesFromStyleAttributes
verifies that inline css in uppercase is translated to lowercase.

Unit test:
emogrifyKeepsAttributeNamesFromCssInOriginalCasing
seems to verify that passed in css does not become lowercase.

I have separately verified that uppercase css in a <style> maintains its uppercase without translation. Is this by design or would you like a pull request to ensure all css is lowercase?

Add media print to the preserved media types

Email tracking tools like https://litmus.com are using follow technique for tracking email prints:

<style>
    @media print {
        #track { 
            background-image: url('http://www.letmeknow.com/print.jpg');
        }
    }
</style>
<div id="track"></div>

Current version from #62 PR strip this media query.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.