Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
e476b60c
Commit
e476b60c
authored
Feb 29, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expanded-style output works (with some whitespace hiccups).
parent
016aabe9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
3 deletions
+57
-3
node.cpp
src/node.cpp
+42
-1
node.hpp
src/node.hpp
+3
-0
test.scss
src/test.scss
+5
-0
unit-test-document.cpp
src/unit-test-document.cpp
+7
-2
No files found.
src/node.cpp
View file @
e476b60c
#include <iostream>
#include "node.hpp"
#include <string>
#include "node.hpp"
using
std
::
string
;
using
std
::
stringstream
;
using
std
::
cout
;
using
std
::
endl
;
...
...
@@ -66,4 +67,43 @@ namespace Sass {
default
:
cout
<<
"HUH?"
;
break
;
}
}
void
Node
::
emit_expanded_css
(
stringstream
&
buf
,
string
prefix
)
{
switch
(
type
)
{
case
value
:
case
selector
:
buf
<<
string
(
token
);
break
;
case
comment
:
buf
<<
string
(
token
)
<<
endl
;
break
;
case
property
:
buf
<<
string
(
token
)
<<
":"
;
break
;
case
values
:
for
(
int
i
=
0
;
i
<
children
.
size
();
++
i
)
buf
<<
" "
<<
string
(
children
[
i
].
token
);
break
;
case
rule
:
buf
<<
" "
;
children
[
0
].
emit_expanded_css
(
buf
,
prefix
);
children
[
1
].
emit_expanded_css
(
buf
,
prefix
);
buf
<<
";"
<<
endl
;
break
;
case
declarations
:
buf
<<
" {"
<<
endl
;
for
(
int
i
=
0
;
i
<
children
.
size
();
++
i
)
children
[
i
].
emit_expanded_css
(
buf
,
prefix
);
buf
<<
"}"
<<
endl
;
for
(
int
i
=
0
;
i
<
opt_children
.
size
();
++
i
)
opt_children
[
i
].
emit_expanded_css
(
buf
,
prefix
);
break
;
case
ruleset
:
buf
<<
prefix
<<
" "
;
children
[
0
].
emit_expanded_css
(
buf
,
prefix
);
children
[
1
].
emit_expanded_css
(
buf
,
prefix
+
string
(
children
[
0
].
token
));
break
;
}
}
}
\ No newline at end of file
src/node.hpp
View file @
e476b60c
#include <vector>
#include <sstream>
#include "token.hpp"
namespace
Sass
{
...
...
@@ -32,5 +33,6 @@ namespace Sass {
void
push_child
(
const
Node
&
node
);
void
push_opt_child
(
const
Node
&
node
);
void
dump
(
unsigned
int
depth
=
0
);
void
emit_expanded_css
(
std
::
stringstream
&
buf
,
string
prefix
);
};
}
\ No newline at end of file
src/test.scss
View file @
e476b60c
...
...
@@ -4,6 +4,11 @@ div {
background
:
blue
;
span
{
font-weight
:
bold
;
a
{
text-decoration
:
none
;
color
:
green
;
}
/* second comment that should be preserved */
display
:
inline-block
;
}
margin
:
10px
5px
;
...
...
src/unit-test-document.cpp
View file @
e476b60c
#include <cstdio>
#include <iostream>
#include <sstream>
#include "document.hpp"
using
namespace
Sass
;
...
...
@@ -50,10 +51,14 @@ int main(int argc, char* argv[]) {
int
i
;
int
j
=
doc
.
statements
.
size
();
printf
(
"%d
\n
"
,
j
)
;
std
::
stringstream
output
;
for
(
i
=
0
;
i
<
j
;
++
i
)
{
doc
.
statements
[
i
].
dump
(
);
doc
.
statements
[
i
].
emit_expanded_css
(
output
,
""
);
}
std
::
cout
<<
output
.
str
();
}
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment