npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remark-uml

v1.0.3

Published

> ⚠️ Since PlantUML is written in Java, this module can't currently be used on the browser. > Investigations are currently being made to try to compile PlantUML to WASM and run it anywhere.

Downloads

17

Readme

remark-uml

⚠️ Since PlantUML is written in Java, this module can't currently be used on the browser. Investigations are currently being made to try to compile PlantUML to WASM and run it anywhere.

remark plugin to compile PlantUML syntax to either images or ASCII art.

Install

With npm:

npm install remark-uml

With yarn:

yarn add remark-uml

Use

Say we have the following file, example.md:

# This is my PlantUML diagram

@startuml
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

**Pretty neat, huh?**

And our script, example.js, looks as follows:

const fs = require('fs');
const remark = require('remark');
const uml = require('remark-uml');

remark()
  .use(uml, { format: 'txt' })
  .process(fs.readFileSync('example.md'))
  .then(output => console.log(output.toString()))

Now, running node example yields:

# This is my PlantUML diagram

```uml
                      ,-.  
                      `-'  
                      /|\  
     ,---.             |   
     |Bob|            / \  
     `-+-'           Alice 
       |    hello      |   
       |-------------->|   
       |               |   
       |  Is it ok?    |   
       |<--------------|   
     ,-+-.           Alice 
     |Bob|            ,-.  
     `---'            `-'  
                      /|\  
                       |   
                      / \  
```

**Pretty neat, huh?**

Note that all the options can also be overridden per diagram by passing a JSON immediately after @startuml. For example, if you want to generate some diagrams as an image and others as an ASCII art, you can do it in this way:

**SVG:**

@startuml{"format": "svg"}
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

**PNG:**

@startuml{"format": "png"}
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

**ASCII:**

@startuml{"format": "txt"}
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

**Unicode:**

@startuml{"format": "utxt"}
participant Bob
actor Alice

Bob -> Alice : hello
Alice -> Bob : Is it ok?
@enduml

As a result, you will get the following output:

Images are actually inlined in the output, but have been moved to external images because some websites don't render inline images in markdown files


SVG:

PNG:

ASCII:

                      ,-.  
                      `-'  
                      /|\  
     ,---.             |   
     |Bob|            / \  
     `-+-'           Alice 
       |    hello      |   
       |-------------->|   
       |               |   
       |  Is it ok?    |   
       |<--------------|   
     ,-+-.           Alice 
     |Bob|            ,-.  
     `---'            `-'  
                      /|\  
                       |   
                      / \  

Unicode:

                      ┌─┐  
                      ║"│  
                      └┬┘  
                      ┌┼┐  
     ┌───┐             │   
     │Bob│            ┌┴┐  
     └─┬─┘           Alice 
       │    hello      │   
       │──────────────>│   
       │               │   
       │  Is it ok?    │   
       │<──────────────│   
     ┌─┴─┐           Alice 
     │Bob│            ┌─┐  
     └───┘            ║"│  
                      └┬┘  
                      ┌┼┐  
                       │   
                      ┌┴┐  

API

remark().use(uml[, options])

options
options.format

The output format of the UML diagrams.

Possible values are:

  • svg: Inline SVG;
  • png: Inline base64-encoded PNG;
  • txt: code block containing the diagram as ASCII art;
  • utxt: same as txt, but using Unicode characters to make the output prettier.

Default value is svg.

options.optimize

Whether to optimize or not the output. Currently only used if options.format is set to svg.

Possible values are:

  • true: Optimize using default options (i.e. { multipass: true });
  • Object: Optimize using custom options. These options are passed directly to SVGO;
  • false | null: Disable optimizations (not recommended).

Default value is true.

options.languageName

The language name to give to the output code block. Used only if options.format is set to txt or utxt.

It can be any string, or a falsy value to disable the language name and make the code block generic.

Default value is uml.

License

MIT