douaoli5328 2014-01-07 06:23
浏览 26

将HTML转换为ENML

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?

  • 写回答

1条回答 默认 最新

  • duanjue7745 2014-01-15 14:34
    关注

    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();
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)