From 27e4f2b541f5bc19f6d579ce060e2b0265956016 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 20 Jun 2020 21:53:01 -0400 Subject: [PATCH] properly parse maps with maps as values --- src/utils/chars.rs | 7 ++++++- tests/map.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/utils/chars.rs b/src/utils/chars.rs index 3b7d711..f0aa466 100644 --- a/src/utils/chars.rs +++ b/src/utils/chars.rs @@ -2,7 +2,7 @@ use peekmore::PeekMoreIterator; use crate::{error::SassResult, Token}; -use super::read_until_closing_quote; +use super::{read_until_closing_paren, read_until_closing_quote}; /// Reads until the char is found, consuming the char, /// or until the end of the iterator is hit pub(crate) fn read_until_char>( @@ -17,6 +17,11 @@ pub(crate) fn read_until_char>( v.extend(read_until_closing_quote(toks, tok.kind)?); continue; } + '(' => { + v.push(tok); + v.extend(read_until_closing_paren(toks)?); + continue; + } t if t == c => break, _ => {} } diff --git a/tests/map.rs b/tests/map.rs index ce4e6ab..53924ba 100644 --- a/tests/map.rs +++ b/tests/map.rs @@ -163,3 +163,17 @@ test!( "a {\n color: inspect(((1, 2): 3));\n}\n", "a {\n color: ((1, 2): 3);\n}\n" ); +test!( + // todo: this just tests that it compiles, but does not test + // if it parses correctly + map_with_map_as_value, + "$foo: (\"21by9\": (x: 21, y: 9));", + "" +); +test!( + // todo: this just tests that it compiles, but does not test + // if it parses correctly + paren_with_paren_element_and_trailing_comma, + "$foo: ((\"<\", \"%3c\"), );", + "" +);