Giter Club home page Giter Club logo

Comments (6)

hashworks avatar hashworks commented on September 27, 2024 1

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.

ZaniaDeveloper avatar ZaniaDeveloper commented on September 27, 2024

Does someone want to take the follow up ?

from c6.

char101 avatar char101 commented on September 27, 2024
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.

corebreaker avatar corebreaker commented on September 27, 2024

@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.

char101 avatar char101 commented on September 27, 2024

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

  1. it stops when it find a comment node because it does not handle comment type in rules.go#L109
  2. 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.

corebreaker avatar corebreaker commented on September 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.