Comments (6)
It's really sad that there is absolutely zero useful documentation on a project with 392 stars. Every not-closed issue is from c9s and there are multiple closed issues asking how to use this, without answers.
I tried to work something out from the parser tests:
package main
import (
"fmt"
"github.com/c9s/c6/parser"
"github.com/c9s/c6/runtime"
)
func main() {
p := parser.NewParser(runtime.NewContext())
stmtList, err := p.ParseScssFile("main.scss")
if err != nil {
fmt.Println(err)
} else {
// ?
}
}
However ParseScssFile
returns *ast.StmtList
and I have no idea how to use it.
from c6.
Does someone want to take the follow up ?
from c6.
package main
import (
"fmt"
"github.com/c9s/c6/parser"
"github.com/c9s/c6/runtime"
"github.com/c9s/c6/compiler"
)
func main() {
context := runtime.NewContext()
parser := parser.NewParser()
stmts, err := p.ParseScssFile("main.scss")
if err != nil {
log.Fatal(err)
}
compiler := compiler.NewCompactCompiler(context)
out := compiler.CompileString(stmts)
ioutil.WriteFile("main.css", []byte(out), 0644)
}
See https://github.com/c9s/c6/blob/master/compiler/compact_compiler_test.go#L8
from c6.
@char101 thank you for your example. I modified it to have something which compiles, that gives:
package main
import (
// "fmt" <--- `fmt` package is not used
"io/ioutil" // <--- `io/ioutil` package is missing
"log" // <--- `log` package is missing
"github.com/c9s/c6/compiler"
"github.com/c9s/c6/parser"
"github.com/c9s/c6/runtime"
)
func main() {
context := runtime.NewContext()
// parser := parser.NewParser() <--- `parser.NewParser()` method asks `context` argument
parser := parser.NewParser(context)
// stmts, err := p.ParseScssFile("main.scss") <--- I suppose p == parser
stmts, err := parser.ParseScssFile("main.scss")
if err != nil {
log.Fatal(err)
}
compiler := compiler.NewCompactCompiler(context)
out := compiler.CompileString(stmts)
ioutil.WriteFile("main.css", []byte(out), 0644)
}
Then, i tried the example on this SCSS file:
/*-----------------------------------------
Colors
----------------------------------------- */
$bordercolor: #ccc;
$iconcolor: #6a737b;
$textcolor: #444;
$background: white;
$itembackground: #e6e7e8;
/*-----------------------------------------
Magic Search bar
----------------------------------------- */
.search-bar {
position: relative;
border: 1px solid $bordercolor;
background-color: $background;
margin-bottom: 0.5rem;
padding: 0.25rem;
height: auto;
i.fi-filter {
color: $iconcolor;
position: absolute;
top: 0.35rem;
left: 0.65rem;
}
.search-main-area {
position: relative;
margin-left: 1.65rem;
margin-right: 1.65rem;
cursor: text;
}
.search-selected {
position: relative;
padding-left: 0;
padding-right: 0;
background-color: $background;
color: $textcolor;
}
.search-entry {
position: relative;
display: inline-block;
height: 1.5rem;
height: 1.5rem;
}
.search-input {
width: 17.5rem;
border: 0;
box-shadow: none;
height: 1.5rem;
padding: 0.25rem;
margin-bottom: 0;
background-color: $background;
&:focus {
box-shadow: none;
background-color: $background;
}
}
.match {
font-weight: bold;
}
i.cancel {
color: $iconcolor;
&:hover {
color: darkred;
}
position: absolute;
top: 0.35rem;
right: 0.65rem;
}
.f-dropdown.open {
left: 0 !important;
}
}
But the produced file main.css
is empty.
from c6.
Sorry, I didn't tried the code before, I only copy pasted it from the test source code.
I have checked it out and it looks like that this compiler is not ready get. I found at least two problems
- it stops when it find a comment node because it does not handle comment type in rules.go#L109
- if you remove all comments from the source, it stops with
String() not implemented yet
error at ruleset.go#L24
Maybe you can use this project instead: go-libass.
from c6.
I think so. What really a pity ! Currently, Libsass is the best alternative.
But a project like c6
should have a good performance improvement compared to Libsass.
from c6.
Related Issues (20)
- Use trie to lex tokens
- Use channel to report syntax error
- Support more math functions
- Supporting regular expression match operator
- @supports syntax
- Use bytes.Buffer to output compiled string instead of normal string concatenation HOT 5
- Type constraint support
- @directive syntax support
- auto import by sorting files in ascending order
- keyword argument parsing HOT 1
- throw undefined function exception nicely
- throw undefined function keyword argument nicely
- c6/lexer: emit POST_COMMENT if there is a comment before the next line
- c6/parser: Add trace mode support
- Introducing @var to fix local variable declaration issue
- Add built-in support for css sprite with device-pixel-ratio HOT 2
- How does compile work? HOT 2
- Example how to compile scss? HOT 10
- Project Status HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c6.