GithubHelp home page GithubHelp logo

connected-world-services / markdown2confluence-cws Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chunpu/markdown2confluence

17.0 2.0 4.0 128 KB

Convert Markdown to Confluence Wiki Markup.

License: ISC License

JavaScript 94.87% Shell 5.13%

markdown2confluence-cws's Introduction

Markdown2Confluence

Convert Markdown to Confluence Wiki Markup. This is an updated version of the original markdown2confluence project.

npm version Build Status Dependencies Dev Dependencies codecov.io

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.

Command-Line Use

Install the tool.

npm install -g markdown2confluence-cws

Use it to convert a markdown file.

markdown2confluence README.md

Or pipe in a file.

cat README.md | markdown2confluence

Library Use

Use npm to install this package easily.

$ npm install --save markdown2confluence-cws

Alternately you may edit your package.json and add this to your dependencies object:

{
    ...
    "dependencies": {
        ...
        "markdown2confluence-cws": "*"
        ...
    }
    ...
}

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

markdown2confluence = require("markdown2confluence-cws");
markdown = fs.readFileSync("README.md");
confluence = markdown2confluence(markdown);
console.log(confluence); // Converted!

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 = markdown2confluence(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. A .renderer property is
    // always added in order to change Markdown to Confluence Wiki Markup.
    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.

markdown2confluence-cws's People

Contributors

chunpu avatar fidian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.