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

@rayzr/markdown2confluence

v2.0.8

Published

Convert Markdown to Confluence Wiki Markup.

Downloads

3

Readme

Markdown2Confluence

npm version dependencies dev dependencies

Convert Markdown to Confluence Wiki Markup. This is an updated version of markdown2confluence-cws, which is a continuation of the original markdown2confluence project.

Overview

Using Markdown is fast becoming a standard for open-source projects and their documentation. There are a few variants, such as GitHub Flavored Markdown, which add additional features.

Atlassian's Confluence has a different way of writing documentation, according to their Confluence Wiki Markup and later pages and references.

This project contains a library and a command-line tool that bridges the gap and converts from Markdown to Confluence.

Library Use

Use npm to install this package easily.

$ npm install --save @rayzr/markdown2confluence

Now you write some JavaScript to load Markdown content and convert.

// Import the module
const { convert } = require('@rayzr/markdown2confluence')
// You can also import as 'markdown2confluence' and then do 'markdown2confluence.convert'

// Read some input
const markdownInput = fs.readFileSync("README.md")

// Convert to Confluence format
const confluenceOutput = convert(markdownInput)

// Converted!
console.log(confluenceOutput)

Alternately, you can use TypeScript as well.

// Import the module
import convert from '@rayzr/markdown2confluence'

// Read some input
const markdownInput = fs.readFileSync("README.md")

// Convert to Confluence format
const confluenceOutput = markdown2confluence(markdown)

// Converted!
console.log(confluenceOutput)

This uses the wonderful marked library to parse and reformat the Markdown text. Because of this, you are welcome to pass additional options to the conversion function. See the marked package for options. Besides configuring marked, you can also change additional behavior.

// Showing how to set two of the options for the marked library.
confluence = convert(markdown, {
    // When code has more than this many lines, set the collapse property
    // so Confluence shows a shorter block of code.
    codeCollapseAt: 20,

    // Map between Markdown and Confluence languages. There's a healthy
    // number of these defined. Setting this property overrides the
    // default mapping. If you want to augment the map, you could
    // add them to markdown2confluence.defaultLanguageMap.
    codeLanguageMap: {
        markdownLanguage: 'confluenceLanguage'
    },

    // Additional code styling options.
    codeStyling: {
        linenumbers: true,
        theme: 'RDark'
    },

    // Rewrite image urls using your own custom logic.
    imageRewrite: href => {
        return href
    },

    // Rewrite link urls using your own custom logic.
    linkRewrite: href => {
        return href
    },

    // These options are passed to marked.
    marked: {
        gfm: true,
        tables: true
    }
})

Supported Markdown

The aim of this library is to convert as much Markdown to Confluence Wiki Markup. As such, most Markdown is supported but there are going to be rare cases that are not supported (such as code blocks within lists) or other scenarios that people find.

If it is possible to convert the Markdown to Confluence Wiki Markup (without resorting to HTML), then this library should be able to do it. If you find anything wrong, it is likely a bug and should be reported. I would need a sample of Markdown, the incorrect translation and the correct way to represent that in Confluence. Please file an issue with this information in order to help replicate and fix the issue.

A good demonstration chunk of markdown is available in demo.md.

What does not work?

  • HTML. It is copied verbatim to the output text.
  • Did you find anything else? Please tell us about it by opening an issue.

License

This software is licensed under an ISC license.