Python Sass binding using Dart Sass
  • Python 94.2%
  • SCSS 2.2%
  • Sass 1.9%
  • CSS 1.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Kazuya Takei 1bf8bdb8ad
Merge pull request #37 from cclauss/codespell
Fix typos discovered by codespell
2026-01-02 23:19:41 +09:00
.github release: Version 0.1.3 2025-09-28 12:23:55 +09:00
docs Fix typos discovered by codespell 2025-12-31 18:15:45 +01:00
examples feat: Low-leve protobuf communicate to Dart Sass host 2025-04-14 02:57:22 +09:00
src/sass_embedded Fix typos discovered by codespell 2025-12-31 18:15:45 +01:00
tests Fix typos discovered by codespell 2025-12-31 18:15:45 +01:00
tools fix(tool): Sync age settings when updated dart-sass 2025-06-26 02:42:12 +09:00
.age.toml release: Version 0.1.3 2025-09-28 12:23:55 +09:00
.editorconfig choer: EditorConfig 2025-09-28 11:23:48 +09:00
.gitattributes chore: Add dotfiles 2025-03-29 12:28:00 +09:00
.gitignore chore: Gnerative AI settings is only on local machine 2025-07-02 21:46:27 +09:00
.python-version chore: Change workspace version 2025-04-08 03:30:29 +09:00
.readthedocs.yaml docs: Configure for Read The Docs 2025-04-13 04:47:42 +09:00
aqua.yaml chore: Update aqua deps 2025-09-28 12:18:23 +09:00
biome.json feat: Simple compile implementation 2025-03-29 21:34:58 +09:00
CHANGES.rst release: Version 0.1.3 2025-09-28 12:23:55 +09:00
create_protobuf.py Fix typos discovered by codespell 2025-12-31 18:15:45 +01:00
hatch_build.py refactor: Add document and comments 2025-03-30 19:30:04 +09:00
lefthook.yaml chore: Use ty 2025-06-21 02:19:09 +09:00
pyproject.toml release: Version 0.1.3 2025-09-28 12:23:55 +09:00
README.rst docs: Write simple usage for PyPI and GitHub 2025-04-26 14:08:21 +09:00
renovate.json5 chore(deps): update dependency aquaproj/aqua-renovate-config to v2.8.2 2025-06-21 11:32:34 +00:00
Taskfile.yaml chore: Revert 2025-09-28 12:00:14 +09:00
uv.lock release: Version 0.1.2 2025-06-26 02:48:50 +09:00

====================
sass-embedded-python
====================

Embedded Sass Host for Python.

.. important::

   This is laboratory stage project. It does not ensure to continue development for goal.

Overview
========

This is Python project to compile Sass/SCSS using `Dart Sass <https://sass-lang.com/dart-sass/>`
that is primary implementation of Sass using Dart runtime.

Simple usage
============

Install:

.. code:: console

   pip install sass-embedded

Source:

.. code:: css
   :name: style.scss

   @use "sass:list";
   @use "sass:color";

   $font-stack: Helvetica, Arial;
   $primary-color: #333;

   body {
     $font-stack: list.append($font-stack, sans-serif);
     font: $font-stack;
   }

   a {
     color: $primary-color;

     &:hover{
       color: color.scale($primary-color, $lightness: 20%);
     }
   }

   @debug $font-stack;

Run:

.. code:: python

   from pathlib import Path
   from sass_embedded import compile_file

   compile_file(Path("style.scss"))

Output:

.. code:: css
   :name: style.css

   body {
     font: Helvetica, Arial, sans-serif;
   }

   a {
     color: #333;
   }
   a:hover {
     color: rgb(91.8, 91.8, 91.8);
   }

Motivation
==========

I develop `sphinx-revealjs <https://pypi.org/project/sphinx-revealjs>`_
that is Python Project to generate HTML presentation from reStructuredText or Markdown.

Reveal.js uses Sass to create presentation themes, and this uses ``sass:color`` module since v5.2.0.
But ``sphinxcontrib-sass`` does not compile themes, because this module is not supported by LibSass.

To resolve it, I am developing optional extension optimized sphinx-revealjs.
Concurrently I will develop generic project for multiple usecases.

This is the side of "generic project".

Project goal
============

Final goal is to have features as same as other "Sass Embedded" libraries.

But I will split some steps for it.

First goal
----------

Works as compile Sass/SCSS with subprocess-based actions.

- Provide single entrypoint to compile sources using Dart Sass native executable.
- Generate Dart Sass bundled bdist files every platforms.

Second goal
-----------

Works as "Sass Embedded Host for Python".

- Support `The Embedded Sass Protocol <https://github.com/sass/sass/blob/main/spec/embedded-protocol.md>`_.

Third goal
----------

Works as alternative to ``libsass-python``.

- Support all api of ``libsass-python`` using Dart Sass native executable.

Support
=======

This project supports only Python 3.9+.

License
=======

I plan for Apache License 2.0.