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

md2pango

v1.0.3

Published

Markdown to Pango Markup Converter

Downloads

12

Readme

md2pango

md2pango

The first Markdown to Pango Markup Converter!

md2pango is a simple regex-based line-by-line converter to convert simple Markdown to Pango Markup.

Purpose

Use Markdown + md2pango to define short texts for small dialogs in lightweight GTK apps. Pango's scope is very limited and thus are md2pango's supported Markdown features. For true richtext support and interactive apps use WebKitGTK.

The project started as part of a Gnome Extension and was later refactored to become a generic NPM module.

Usage

To use it in a GTK app, first add src/md2pango.js to the imports; either by just copying the file or during packaging.

// Gnome Extension, with `md2pango.js` copied next to your `extension.js`
const md2pango = Me.imports.md2pango

// GTK app
imports.searchPath.unshift('path/to/md2pango')
const md2pango = imports.md2pango

// node.js app after installing the md2pango module
const md2pango = require('md2pango')

Thereafter just use md2pango.convert(str:String) -> str:String.

let pangoText = md2pango.convert('### Heading')
// pangoText: <big>Heading</big>

CLI Mode

The module comes with a installable binary md2pango.

Using md2pango FILE [FILE...] one or more Markdown files can be converted to Pango Markup. The result is written to process.stdout.

Use it to convert Markdown files in your Pango/GTK projects if you cannot or don't want to ship md2pango.js with your code.

Converted Elements

   headings:         #, ##, ###, ===, ---
   unordered list:   * item
   ordered list:     1. item
   escaping:         <, >, &
   code block start: ```, ```lang
   code block stop:  ```
   inline styles:    **bold**, *emph*, `fixed`
   inline urls:      [name](link)
   url detection:    http[s]?://.*
   comments:         <!-- -->
   color marcos:     <!--fg|bg=COLOR|#RGB-->

Macros

Pango colors can be set as Markdown comments using <!--fg=#RGB bg=#RGB-->. Color names instead of #RGB are also supported. Use <!--/--> to close the currently coloring block. Currently, colors modifications cannot be nested. Use only one macro per line!

Limitations

  • All undetected markdown features will be escaped and converted as regular text.
  • Multiple URIs on one line may cause trouble.
  • Valid but unsupported Markdown/Pango XML tags are escaped and converted as regular text.
  • Conversion and escaping are best effort (there are probably some ways to break it).
  • The effects of nesting styles are unpredictable (requires a smarter Markdown parser).
  • Multi-line list items are not supported.

Licenses

Code: MIT

Visuals: CC-BY-4.0

Contributing

When making changes to the project, please ensure that all changes also work in GJS/GTK apps and in Gnome Extensions. Also see CONTRIBUTING.md.