eafer/rdrview

Option to keep class attributes in the processed HTML

Closed this issue · 4 comments

I've created an application that converts web pages to PDF using LuaLaTeX. It uses rdrview to clean-up the HTML code before passing it to Lua post-processing. Users can use Lua scripts to change the way how various HTML elements are transformed to LaTeX. These transformation functions support CSS selectors to apply rules. Quite ofthen, you will want to apply some specific styles to elements with particular classes, but I've found that rdrview removes class attributes from the generated HTML.

I've found this comment in the source code:

  • fx: Removes the class="" attribute [...], except those that match
  • CLASSES_TO_PRESERVE and the classesToPreserve array from the options object.
  • TODO: add cli option to preserve other classes, or all of them

So my question is: would it be possible to add cli option to preserve all classes? It would be really useful for my use case.

So my question is: would it be possible to add cli option to preserve all classes?

Sure, that shouldn't be hard. I'll try to get it done this weekend.

Sounds great, thanks!

I just tagged a release that adds a --preserve-classes option. When you can let me know if it helps.

This is exactly what I needed, thanks! It works perfectly.