Convert HTML to ENML

I'm trying to write an extension for Gmail that allows you to save mail as a note in Evernote, but Evernote ENML is pretty strict , because in, it does not allow using external styles.

So what I want to do is something like this -
- convert external styles to inline ones,
- check / balance tags
- clear tags that Evernote considers offensive

So, before I try to move on to writing the parser above, does anyone know a php library that is already doing a heavy lift?

If not, what is the way to go with the above requirement?

+4
source share
1

, https://github.com/tijsverkoyen/CssToInlineStyles. packagist .

:

<?php

// ...

use \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;

// ...

$css = file_get_contents('./content.html');

// create instance
$cssToInlineStyles = new CssToInlineStyles();
$css = file_get_contents('./styles.css');

$cssToInlineStyles->setHTML($content);
$cssToInlineStyles->setCSS($css);

$mail_content = $cssToInlineStyles->convert();
+1

All Articles