Rust for a Pythonista #2: Building a Rust crate for CSS inlining

It is the second part of a series about Rust for Python users.

In this article, we will build a foundation for a Rust-powered Python library - a crate that implements CSS inlining. It is a process of moving CSS rules from style tags to the corresponding spots in the HTML body. This approach to including styles is crucial for sending HTML emails or embedding HTML pages into 3rd party resources.

Our goal is to build a library that will transform this HTML:

<html>
    <head>
        <style>h1 { color:blue; }</style>
    </head>
    <body>
        <h1>Big Text</h1>
    </body>
</html>

into this:

<html>
    <head>
        <style>h1 { color:blue; }</style>
    </head>
    <body>
        <h1 style="color:blue;">Big Text</h1>
    </body>
</html>

We'll go through:

Target audience: Those who know Rust common principles and looking for practical examples. Some familiarity with trait bounds and generics is helpful.

Read more  ↩︎

Rust for a Pythonista #1: Why and when?

Rust is getting more popular among software developers, and the Python community is no exception. I started learning Rust a few years ago, but after some point, I began to lose motivation because most of my exercises were toy examples and far away from the real applications. So I questioned myself:

  • Can I use Rust in my day-to-day job as a Python developer?
  • Can I build something that will benefit the projects I am working with?

Probably, many of us, people coming from the Python background, had similar thoughts. In a 3 chapter series, I will share my experience with embedding Rust into Python projects and try to give you some options that may answer such questions.

Update (2020-08-06): More links to popular Rust-powered tools & thread-safety note

Read more  ↩︎