Skip to content

Commit b041aa1

Browse files
committed
Remove css macro.
1 parent 9a664aa commit b041aa1

File tree

7 files changed

+1
-283
lines changed

7 files changed

+1
-283
lines changed

html-node-macro/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ syn = "2"
2727
syn_derive = { version = "0.1", optional = true }
2828

2929
[features]
30-
basic-css = []
3130
typed = ["dep:syn_derive"]

html-node-macro/src/lib.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,14 @@ use proc_macro::TokenStream;
1717
use proc_macro2::{Ident, TokenStream as TokenStream2};
1818
use proc_macro2_diagnostics::Diagnostic;
1919
use quote::quote;
20-
#[cfg(feature = "basic-css")]
21-
use quote::quote_spanned;
2220
use rstml::{node::Node, Parser, ParserConfig};
23-
#[cfg(feature = "basic-css")]
24-
use syn::spanned::Spanned;
2521
use syn::Type;
2622

2723
#[proc_macro]
2824
pub fn html(tokens: TokenStream) -> TokenStream {
2925
html_inner(tokens.into(), None)
3026
}
3127

32-
#[cfg(feature = "basic-css")]
33-
#[proc_macro]
34-
pub fn style(tokens: TokenStream) -> TokenStream {
35-
style_inner(tokens.into())
36-
}
37-
3828
#[cfg(feature = "typed")]
3929
#[proc_macro]
4030
pub fn typed_html(tokens: TokenStream) -> TokenStream {
@@ -179,37 +169,3 @@ fn tokenize_nodes(
179169

180170
(token_streams, diagnostics)
181171
}
182-
183-
/// Naive conversion of a rust token stream into css content.
184-
///
185-
/// Strips all whitespace from the given tokens, concatenates them into a
186-
/// single string and returns a token stream of the given css content
187-
/// wrapped in an HTML style tag.
188-
#[cfg(feature = "basic-css")]
189-
fn style_inner(tokens: TokenStream2) -> TokenStream {
190-
let span = tokens.span();
191-
let raw_css = tokens
192-
.into_iter()
193-
.map(|token_tree| {
194-
token_tree
195-
.to_string()
196-
.split_whitespace()
197-
.collect::<String>()
198-
})
199-
.collect::<String>();
200-
201-
quote_spanned! { span=>
202-
::html_node::Node::Element(
203-
::html_node::Element {
204-
name: ::std::convert::Into::<::std::string::String>::into("style"),
205-
attributes: ::std::vec::Vec::new(),
206-
children: ::std::option::Option::Some(
207-
::std::vec![
208-
::html_node::Node::UnsafeText(#raw_css.into())
209-
]
210-
)
211-
}
212-
)
213-
}
214-
.into()
215-
}

html-node/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ required-features = ["axum"]
2525
name = "typed_custom_attributes"
2626
required-features = ["typed"]
2727

28-
[[example]]
29-
name = "styling"
30-
required-features = ["basic-css"]
31-
3228
[dependencies]
3329
html-node-core = { path = "../html-node-core" }
3430
html-node-macro = { path = "../html-node-macro" }
@@ -40,7 +36,6 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
4036

4137
[features]
4238
axum = ["html-node-core/axum"]
43-
basic-css = ["html-node-macro/basic-css"]
4439
pretty = ["html-node-core/pretty"]
4540
serde = ["html-node-core/serde"]
4641
typed = ["html-node-core/typed", "html-node-macro/typed"]

html-node/examples/axum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
};
55

66
use axum::{extract::Query, routing::get, Router, Server};
7-
use html_node::{html, style, text, Node};
7+
use html_node::{html, text, Node};
88
use html_node_core::pretty::Pretty;
99

1010
#[tokio::main]

html-node/examples/styling.rs

Lines changed: 0 additions & 191 deletions
This file was deleted.

html-node/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,5 @@ pub use html_node_core::{Comment, Doctype, Element, Fragment, Node, Text, Unsafe
147147
///
148148
/// See the [crate-level documentation](crate) for more information.
149149
pub use html_node_macro::html;
150-
/// Experimental proc-macro allowing for the direct insertion of CSS into a
151-
/// [`Node`].
152-
///
153-
/// This is a partial work-around for the fact that parsing raw CSS into a Rust
154-
/// token-stream will clobber the CSS syntax, making it unparseable by the
155-
/// browser, and leaving content unstyled.
156-
///
157-
/// See the [styling example](../html-node/styling.rs) for more information on
158-
/// how styles are parsed by this library and how the [`style!()] macro is used
159-
/// to work-around some of the inevitable shortcomings.
160-
#[cfg(feature = "basic-css")]
161-
pub use html_node_macro::style;
162150

163151
pub use self::macros::*;

html-node/tests/main.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,3 @@ fn pretty_printed_helper() {
124124
</div>"#;
125125
assert_eq!(expected, pretty_html.to_string());
126126
}
127-
128-
#[cfg(feature = "basic-css")]
129-
#[test]
130-
fn css_style_macro() {
131-
let style = html_node::style! {
132-
#id {
133-
outline-width: 5px;
134-
outline-style: solid;
135-
outline-color: #CCDDFF;
136-
}
137-
.class,div {
138-
background-color: rgb(123, 253, 48);
139-
}
140-
};
141-
let expected = "\
142-
<style>\
143-
#id{\
144-
outline-width:5px;\
145-
outline-style:solid;\
146-
outline-color:#CCDDFF;\
147-
}\
148-
.class,div{\
149-
background-color:rgb(123,253,48);\
150-
}\
151-
</style>\
152-
";
153-
154-
assert_eq!(style.to_string(), expected);
155-
}

0 commit comments

Comments
 (0)