Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
sass
Description
This egg is a wrapper for libsass, the C/C++ library version of the Sass CSS preprocessor. As of version 0.1, it is just a literal translation of the C API.
TOC »
Authors
Matt Gushee <matt@gushee.net>
Requirements
High-level API
Usage
(use sass)
Procedures
- compile-file FILENAME #!key kwargsprocedure
- compile-string STRING #!key kwargsprocedure
- compile-from-port PORT #!key kwargsprocedure
compile-file, compile-string, and compile-from-port accept the following keyword arguments:
- output
- [string/port - default 'stdout] The destination for the output. May be a filename, a port, or the symbol 'stdout.
- precision
- [integer - default #f] The precision, in number of digits, for decimal numbers.
- output-style
- [symbol - default #f] One of 'nested, 'expanded, 'compact, or 'compressed. This option controls the formatting of the output CSS.
- source-comments
- [boolean - default 'undefined] This option controls whether comments are placed in the output to identify the line number in the source file where each selector is defined.
- source-map-embed
- [boolean - default 'undefined] Whether to embed sourceMappingUrl as data URI.
- source-map-contents
- [boolean - default 'undefined] Whether to embed include contents in sourcemap files.
- omit-source-map-url
- [boolean - default 'undefined] Whether to disable sourceMappingUrl in CSS output.
- is-indented-syntax-src
- [boolean - default 'undefined] Assume source file format is SASS rather than SCSS.
- indent
- [string - default #f] The string to use for indentation.
- linefeed
- [string - default #f] The string to use for linefeeds.
- input-path
- [string - default #f] Input path for source map generation.
- output-path
- [string - default #f] Output path for source map generation.
- plugin-path
- [string - default #f] A list of paths - semicolon-separated on Windows, colon-separated otherwise.
- include-path
- [string - default #f] A list of paths - semicolon-separated on Windows, colon-separated otherwise.
- source-map-file
- [string - default #f] Path of a source map file. If non-empty, enables source map generation.
- source-map-root
- [string - default #f] Root directory inserted in source maps.
- c-headers
- [default #f] No documentation available.
- c-importers
- [default #f] Overload imports.
- c-functions
- [default #f] List of custom functions callable from SCSS code.
Low-level API
The following documents the entire sass-context API, which is the primary public interface to the C library. The sass-values and sass-functions modules are currently undocumented.
Usage
(use sass-context)
TYPES
All the following are foreign types, and can only be created using the appropriate API functions.
- OPTIONStype
Represents a key-value structure of options. Use make-options or get-options to create.
- INPUT-CONTEXTtype
A record type wrapping either of the foreign pointer types Sass_File_Context or Sass_Data_Context, which represent, respectively, the input file or string. Use make-file-context or make-data-context to create.
- CONTEXTtype
Represents the output. Use get-context to create.
- SASS-COMPILERtype
Represents the compiler. Use make-compiler to create.
PROCEDURES
- make-optionsprocedure
Returns an OPTIONS object.
- make-file-context FILENAMEprocedure
Returns an INPUT-CONTEXT object with type tag 'file.
- make-data-context INPUT-STRINGprocedure
Returns an INPUT-CONTEXT object with type tag 'data.
- compile-input-context INPUT-CONTEXTprocedure
The usual method to invoke compilation of a stylesheet.
- make-compiler INPUT-CONTEXTprocedure
Returns a SASS-COMPILER object.
- compiler-parse SASS-COMPILERprocedure
- compiler-execute SASS-COMPILERprocedure
- delete-compiler SASS-COMPILERprocedure
- delete-input-context INPUT-CONTEXTprocedure
- get-context INPUT-CONTEXTprocedure
Returns a CONTEXT object.
- get-options CONTEXT/INPUT-CONTEXTprocedure
- set-options! INPUT-CONTEXT OPTIONSprocedure
- opt-precision SASS-OPTIONSprocedure
- opt-output-style SASS-OPTIONSprocedure
- opt-source-comments SASS-OPTIONSprocedure
- opt-source-map-embed SASS-OPTIONSprocedure
- opt-source-map-contents SASS-OPTIONSprocedure
- opt-omit-source-map-url SASS-OPTIONSprocedure
- opt-indent SASS-OPTIONSprocedure
- opt-linefeed SASS-OPTIONSprocedure
- opt-input-path SASS-OPTIONSprocedure
- opt-output-path SASS-OPTIONSprocedure
- opt-plugin-path SASS-OPTIONSprocedure
- opt-include-path SASS-OPTIONSprocedure
- opt-source-map-file SASS-OPTIONSprocedure
- opt-source-map-root SASS-OPTIONSprocedure
- opt-c-headers SASS-OPTIONSprocedure
- opt-c-importers SASS-OPTIONSprocedure
- opt-c-functions SASS-OPTIONSprocedure
- opt-indent-set! SASS-OPTIONS STRINGprocedure
- context-get-error-json SASS-CONTEXTprocedure
- context-get-error-text SASS-CONTEXTprocedure
- context-get-error-file SASS-CONTEXTprocedure
- context-get-error-src SASS-CONTEXTprocedure
- context-get-error-line SASS-CONTEXTprocedure
- context-take-error-json SASS-CONTEXTprocedure
- context-take-error-text SASS-CONTEXTprocedure
- context-take-error-file SASS-CONTEXTprocedure
- compiler-get-state SASS-COMPILERprocedure
- compiler-get-context SASS-COMPILERprocedure
Examples
simple.scm
Here is a simple file compiler using the sass-context API. This example is adapted from https://github.com/sass/libsass/wiki/API-Sass-Context-Example.
(use (prefix sass sass:)) (define (main) (let* ((args (command-line-arguments)) (infile (if (null? args) "styles.scss" (car args))) (file-ctx (sass:make-file-context infile)) (ctx (sass:get-context file-ctx)) (ctx-opts (sass:get-options ctx))) (sass:opt-precision-set! ctx-opts 10) (let ((status (sass:compile-input-context file-ctx))) (if (zero? status) (display (sass:output-string ctx)) (error (sass:error-message ctx)))) (sass:delete-input-context file-ctx))) (main)
To use this example:
csc simple.scm echo "foo { margin: 21px * 2; }" > foo.scss ./simple foo.scss => "foo { margin: 42px }"
In case of bugs
If you have a GitHub account, please use the GitHub issue tracker -- likewise for any technical questions or suggestions you may have (other than how-to type questions). If you are unable to do this, the chicken-users mailing list will also work.
License
Copyright (c) 2015, Matthew C. Gushee All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Repo
https://github.com/mgushee/chicken-sass
Version History
- 0.2
- [June 3, 2015] Added high-level compile-* procedures; merged FILE-CONTEXT and DATA-CONTEXT types into new INPUT-CONTEXT type; made sass-context API names more concise; moved csass program into new csass-utils egg.
- 0.1
- Initial release.