fix include_sass test

This commit is contained in:
connorskees 2023-01-07 17:08:42 +00:00
parent 16ad7298fe
commit d7962e02be
4 changed files with 9 additions and 14 deletions

View File

@ -124,11 +124,9 @@ impl ListSeparator {
} }
} }
/// In Sass, underscores and hyphens are considered equal /// In Sass, underscores and hyphens are considered equal when inside identifiers.
/// when inside identifiers.
/// ///
/// This struct protects that invariant by normalizing all /// This struct protects that invariant by normalizing all underscores into hypens.
/// underscores into hypens.
#[derive(Clone, Eq, PartialEq, Hash, PartialOrd, Ord, Copy)] #[derive(Clone, Eq, PartialEq, Hash, PartialOrd, Ord, Copy)]
pub(crate) struct Identifier(InternedString); pub(crate) struct Identifier(InternedString);

View File

@ -183,15 +183,14 @@ fn from_string_with_file_name<P: AsRef<Path>>(
/// Compile CSS from a path /// Compile CSS from a path
/// ///
/// n.b. grass does not currently support files or paths that are not valid UTF-8 /// n.b. `grass` does not currently support files or paths that are not valid UTF-8
/// ///
/// ``` /// ```
/// fn main() -> Result<(), Box<grass::Error>> { /// fn main() -> Result<(), Box<grass::Error>> {
/// let sass = grass::from_path("input.scss", &grass::Options::default())?; /// let css = grass::from_path("input.scss", &grass::Options::default())?;
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[inline] #[inline]
pub fn from_path<P: AsRef<Path>>(p: P, options: &Options) -> Result<String> { pub fn from_path<P: AsRef<Path>>(p: P, options: &Options) -> Result<String> {
from_string_with_file_name(String::from_utf8(options.fs.read(p.as_ref())?)?, p, options) from_string_with_file_name(String::from_utf8(options.fs.read(p.as_ref())?)?, p, options)
@ -201,12 +200,11 @@ pub fn from_path<P: AsRef<Path>>(p: P, options: &Options) -> Result<String> {
/// ///
/// ``` /// ```
/// fn main() -> Result<(), Box<grass::Error>> { /// fn main() -> Result<(), Box<grass::Error>> {
/// let sass = grass::from_string("a { b { color: &; } }".to_string(), &grass::Options::default())?; /// let css = grass::from_string("a { b { color: &; } }".to_string(), &grass::Options::default())?;
/// assert_eq!(sass, "a b {\n color: a b;\n}\n"); /// assert_eq!(css, "a b {\n color: a b;\n}\n");
/// Ok(()) /// Ok(())
/// } /// }
/// ``` /// ```
#[inline] #[inline]
pub fn from_string(input: String, options: &Options) -> Result<String> { pub fn from_string(input: String, options: &Options) -> Result<String> {
from_string_with_file_name(input, "stdin", options) from_string_with_file_name(input, "stdin", options)

View File

@ -4,9 +4,8 @@ use crate::{Fs, StdFs};
/// Configuration for Sass compilation /// Configuration for Sass compilation
/// ///
/// The simplest usage is `grass::Options::default()`; /// The simplest usage is `grass::Options::default()`; however, a builder pattern
/// however, a builder pattern is also exposed to offer /// is also exposed to offer more control.
/// more control.
#[derive(Debug)] #[derive(Debug)]
pub struct Options<'a> { pub struct Options<'a> {
pub(crate) fs: &'a dyn Fs, pub(crate) fs: &'a dyn Fs,

View File

@ -3,5 +3,5 @@
fn basic() { fn basic() {
let css: &str = grass::include!("./input.scss"); let css: &str = grass::include!("./input.scss");
assert!(css == "a {\n color: red;\n}\n"); assert_eq!(css, "a{color:red}");
} }