Skip to content

nandac/niram-css

 
 

Repository files navigation

The niram-css Package

Version 0.2.0

niram-css1 brings standard CSS color names2 to Typst.

While Typst natively ships with eighteen predefined colors, using anything outside that set usually means hunting down a hex code. niram-css eliminates this friction by giving you access to the standard CSS color names. Instead of writing #c71585, you can just write mediumvioletred.

Key features:

  • Complete CSS Color Support: Access all 147 standard CSS color names.3

  • Flexible Naming Convention: Write color names in whatever form feels most natural to you. Inputs are automatically normalized, meaning mediumvioletred, medium violet red, Medium Violet Red, medium-violet-red, medium_violet_red, mediumVioletRed, MediumVioletRed, MEDIUM_VIOLET_RED, and MEDIUMVIOLETRED will all resolve to the same color.

Requirements

This package requires Typst 0.13.0 or higher.

Getting Started

Import the package at the top of your Typst document:

#import "@preview/niram-css:0.2.0": *

Then, use the css function anywhere a color value is expected:

This is #text(fill: css("mediumvioletred"))[mediumvioletred] text.
Text colored with the CSS color mediumvioletred

That is all it takes to start using CSS color names in your document.

For more examples, please refer to the official manual.

Development

If you wish to contribute to this package, follow the steps below to prepare your development environment. The package source is in src/lib.typ.

  1. Typst: Install Typst (version 0.13.0 or higher) following the Typst installation guide. Typst is the core tool required for this project.

  2. Just: Install Just, a command runner for executing predefined tasks. Refer to the available packages for installation instructions specific to your operating system.

  3. tytanic: Install tytanic, a library essential for testing and working with Typst projects. Use the quickstart installation guide to get it up and running.

  4. Clone the Repository: Download the project's source code by cloning the repository to your local machine:

    git clone https://github.com/nandac/niram-css.git

    Your development environment is now ready.

Running Tests

To validate the package functionality, execute the following command:

just test

To add a new test case execute:

tt new <test-case-name>

This will create a new folder with the following structure under the tests directory:

├── <test-case-name>
│   ├── .gitignore
│   ├── ref
│   │   └── 1.png
│   └── test.typ

You may then write your tests in the test.typ file.

For more information on writing tests using tytanic please see this guide.

Once you have written your test run:

just update
just test

Ensure all tests pass before submitting changes to maintain code quality.

To test the package with an actual Typst file, install the niram-css package locally in the preview location by running:

just install-preview

Once installed, import it into your Typst file using:

#import "@preview/niram-css:0.2.0": *

This allows experimentation with the package before finalizing updates.

Releasing a New Version

Follow these steps to release a new version of the package:

  1. Update Version Number:

    • Increment the major and/or minor version number in all files referencing the old version.
  2. Update CHANGELOG:

    • Document added features, modifications, and optionally include a migration guide for the new version in CHANGELOG.md.
    • Use the guidelines given at Keep a Changelog.
  3. Commit Changes:

    • Push your updates to the repository:

      git add -u
      git commit -m "Bump version and update CHANGELOG"
      git push
  4. Tag the Release:

    • Create and push a new tag for the version:

      git tag -a v<version> -m "<release-text>"
      git push --tags origin
  5. Create a Pull Request:

    • The release action in GitHub will create a branch in your fork of typst-packages.
    • Use this branch to open a pull request in the main Typst Packages repository.

Acknowledgments

Special thanks to the Typst community on Discord for their invaluable assistance and support during the development of this package.

Footnotes

  1. In Tamil, niram (நிறம், /n̪ɪrɐm/) means "color"—a fitting name for a coloring package.

  2. While the official W3C specification refers to these as "color keywords," they are almost universally known among web developers as "color names." This documentation uses the common vernacular for readability.

  3. You may also view these colors in a web browser.

About

Brings standard CSS color names to Typst.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Typst 79.5%
  • Shell 14.9%
  • Just 5.6%