Rendering Code Blocks into Images with lookatme.contrib.render
Are you tired of plain and monotonous code blocks in your markdown files? Look no further! Introducing lookatme.contrib.render, an extension for lookatme that enables the rendering of code blocks into images. With this extension, you can enhance the visual presentation of your code snippets and make them more engaging for your readers.
To get started with lookatme.contrib.render, you need to have an image-rendering contrib extension installed for lookatme. One popular option is lookatme.contrib.urwid_ueberzug, which allows the display of images. Make sure you have this extension installed before proceeding.
Installation
To install lookatme.contrib.render, simply run the following command using pip:
bash
pip install lookatme.contrib.render
Usage
Once you have installed the extension, you can enable it by adding it to the metadata in the head of your markdown file:
“`txt
title:
author:
extensions:
– render
“`
Supported Languages
lookatme.contrib.render currently supports the following languages:
-
dot
,graphviz
: This language uses the Graphviz renderer. Make sure you have Graphviz installed by runningapt-get install graphviz
. -
mermaid
: This language uses the mermaid.cli renderer. To use it, you need to install mermaid.cli by runningnpm install mermaid.cli
and add it to your PATH by runningexport PATH="$PATH:$(pwd)/node_modules/.bin"
.
To specify the height of the rendered image, you can append -N
or N
to the code block language, where N
represents the number of rows the image should use when displayed.
Here’s an example of rendering a mermaid-js graph with a height of 10 rows:
~~~
mermaid-10
graph TD
A0 -> B
A1 -> B
B -> C
C -> D
~~~
This will produce an image of the mermaid-js graph with a height of 10 rows.
For more examples and detailed information, please refer to the lookatme.contrib.render repository.
In conclusion, the lookatme.contrib.render extension provides a powerful way to enhance the visual presentation of code blocks in markdown files. By rendering code into images, you can create more engaging and visually appealing content. Whether you want to showcase graphs, diagrams, or any other supported language, lookatme.contrib.render has you covered. Give it a try and take your code presentation to the next level!
If you have any questions or need further assistance, please feel free to ask.
Leave a Reply