🚧 This module is in early developement, expect breaking changes 🚧
Also not yet released in any repository. Until than, you can use it with the raw urls
Enables you, to render a markdown text into a string, which printed in the terminal provides a formatted output, instead of plain text.
As its core, it currently uses https://github.com/syntax-tree/mdast-util-from-markdown, to get the AST
.
This module draws heavily from @dephraims work with https://github.com/dephraiim/termd.
To see a general capabilities of this module run:
deno run https://raw.githubusercontent.com/littletof/terminal_markdown/master/example.ts
To see, how a specific markdown gets rendered run:
deno run --allow-read https://raw.githubusercontent.com/littletof/terminal_markdown/master/example.ts ./README.md
import { renderMarkdown } from 'https://raw.githubusercontent.com/littletof/terminal_markdown/master/mod.ts';
const md = Deno.readTextFileSync(Deno.args[0]);
console.log(renderMarkdown(md));
The main functions are also exported from the module, so you can use the toAST
function to get your ast for the markdown and process it yourself.
Also, since its a wrapper for mdast-util-from-markdown, you can pass extensions
to it in the options, which should work too.
For direct use in the terminal run cli.ts
:
deno run --allow-net https://raw.githubusercontent.com/littletof/terminal_markdown/master/cli.ts -r https://raw.githubusercontent.com/denoland/deno/master/README.md
Or install it with deno install
It has three options:
-s
for rendering a string directly: -s "# markdown string"
-l
for rendering a local file: -l ./README.md
-r
for rendering a remote file: -r https://raw.githubusercontent.com/denoland/deno/master/README.md
The module itself requires no permissions to run.
These could change in the future, but the aim is to keep minimal complexity.
Feedback and contributions are always welcome. Open an issue or a PR, or contact me on the Deno discord.
# Header with *italic*
Author: littletof
Source Code: https://github.com/littletof/terminal_markdown
#deno #nodejs #node #javascript