inline-css 0.0.3

Embed CSS directly in your Rust code
Documentation
// Copyright (C) 2023 Benjamin Stürz
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
use super::*;

impl inline_xml::ToXml for CSS {
    fn to_xml(&self) -> inline_xml::Xml {
        use inline_xml::*;
        let xml = self
            .to_string()
            .trim_end_matches('\n')
            .split('\n')
            .map(|s| Content::Word(s.to_string()))
            .collect();
        Xml(xml)
    }
}

#[cfg(test)]
mod tests {
    use crate as inline_css;
    use inline_xml::xml;
    use crate::css;

    #[test]
    fn simple() {
        let css = css! {
            h1 {
                color: red;
            }
        };
        let _html = xml! {
            <html>
                <head>
                    <style>{css}</style>
                </head>
                <body>
                    <h1>Title</h1>
                </body>
            </html>
        };
    }
}