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.
Due to my inexperience with emacs, I am only able to show how to install it with Doom Emacs (which is what I use):
-
Add the following code to your
packages.el
(package! carbon-mode :recipe (:host github :repo "alvarezGarciaMarcos/carbon-mode.el") )
-
Add the following code to your
config.el
(require 'carbon-mode)
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).
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 |
- 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.