/carbon-mode.el

A little package that will help you to make your code snippets a little bit prettier.

Primary LanguageEmacs Lisp

Table of Contents

  1. Carbon-mode
  2. Installation
  3. How to use
    1. List of arguments
  4. Notes

Carbon-mode

This little emacs package is aimed to add some beauty to code snippets. It is using Carbonara Project (which internally uses Carbon) to create an elegant image of your code.

Installation

Due to my inexperience with emacs, I am only able to show how to install it with Doom Emacs (which is what I use):

  1. Add the following code to your packages.el

    (package! carbon-mode
     :recipe (:host github :repo "alvarezGarciaMarcos/carbon-mode.el") )
    
  2. Add the following code to your config.el

    (require 'carbon-mode)
    

How to use

To use carbon-mode you have to create a script tag like the following:

#+BEGIN_SRC carbon :language javascript :filename image1 :background "#FFFFFF"
     function greet(){
         console.log("Thank you for using carbon-mode");
     }
#+END_SRC

Inside the script tag you have to place the code to be exported to an image.

Once you have entered the code you want to prettify, you just have to press C-c C-c (or RET if you are using Doom Emacs). This will move your cursor above the script tag, fetch a new image from Carbonara and save it under the folder ./images with the name that you have provided in the header.

This is the image that is generated by carbon-mode (inside the ./images/ folder you can see in this repo). img

List of arguments

This are all the possible arguments to use with the mode:

Arguments Required Description
:language yes The language you want the syntax-highlighting
:filename yes The filename that your image will have
:background yes The background that your image will have

Notes

  • Right now you have to manually delete the code used to generate the image, this way you can re-generate the code how many times you want and delete the code once the result satisfies you.