I am trying to write an extension for Gmail that lets you save mail as a note in Evernote, but Evernote's ENML is pretty strict, as in, it doesn't allow external styles.
So what I am looking to do is something like so -
- convert external styles to inline,
- validate/balance the tags
- purify the tags that Evernote considers offensive
So before I try to jump into writing a parser for above, does anyone know of a php library that is already doing the heavy lifting?
If not, what is the way to go with above requirement?
If the only interesting problem is converting external styles to inline styles you can use https://github.com/tijsverkoyen/CssToInlineStyles. It also has a composer package at packagist for easy deployment.
I used it like this:
<?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();