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

turndown-redmine

v0.3.0

Published

Library for converting HTML to Redmine-friendly Markdown

Downloads

11

Readme

turndown-redmine

turndown-redmine is an HTML to GitHub Flavored Markdown converter designed to work well for Redmine as the text destination.

Technically, it is an opinionated extension and configuration of Turndown that recognizes Redmine-specific constructs like macros and improves Turndown in several ways. The holy grail is to fully pass backtranslation tests and we are very close.

turndown-redmine is able to transform specifics of HTML generated by Redmine and JIRA and create Redmine constructs like attachment links accordingly. There are two main use cases:

  • Automatic format conversions
  • WYSIWYG editing

Installation and usage

Using npm:

npm install turndown-redmine

In Node.js:

const TurndownRedmine = require('turndown-redmine');

Synopsis

const turndownRedmine = new TurndownRedmine();
const markdown = turndownRedmine.turndown(str);

Options

Options can be passed in to the constructor on instantiation.

| Option | Valid values | Default | | ------| ----------- | ------ | | fontColor | true or false | false | | attachmentUrlPatterns | RegExp | [/^\/secure\/attachment\/\d+\/\d+_([^/]+)$/,/^\/attachments\/download\/\d+\/([^/]+)$/] | | codeClassPatterns | RegExp | [/^(?:language\|code)-(\S+)$/, /^(\S+)\s+syntaxhl$/] | | fence | ``` or ~~~ | ``` | | listSeparator | any string | \n<!-- end list -->\n | | listItemPadding | any integer | 0 | | citeDelimiter | <cite> or * | <cite> | | preformattedCode | true or false | true | | htmlEncodedRedmineMacros | true or false | true | | thumbnailMacro | true or false | true | | collapseMacro | true or false | true | | collapseMacroDefaultArgs | Array of 2 string values | ['Show', 'Hide'] |

  • fontColor - Specifies whether colorized text should be rendered or not.
  • attachmentUrlPatterns - Array of RegExp patterns which match attachments name in URL.
  • codeClassPatterns - Array of RegExp patterns which match code language in code blocks.
  • fence - Code fence of fenced code block.
  • listSeparator - Separator of consecutive lists.
  • citeDelimiter - Specifies delimiter to be used for rendering <cite> element.
  • preformattedCode - treat inline code as preformatted, should be considered rather experimental, as correct escaping is not yet guaranteed
  • htmlEncodedRedmineMacros - see redmine_reformat's RedmineFormatter for more details
  • thumbnailMacro - use Redmine {{thumbnail}} macro for recognized image thumbnails.
  • collapseMacro - use Redmine {{collapse}} macro for recognized collapsed text.
  • collapseMacroDefaultArgs - Array of 2 string values that should be considered as default collapse macro arguments. Macros with matching arguments will be rendered with no arguments. Order of Array members is important.

Example

const TurndownRedmine = require('turndown-redmine');

const turndownRedmine = new TurndownRedmine();
const markdown = turndownRedmine.turndown('<h1>text</h1>');

Produces:

# text

Implementation details

Compared to Turndown, TurndownRedmine additionally uses two sets of rules:

  1. Tables by Turndown plugin GFM
  2. Custom rules for Redmine, which can be found in TurndownPluginRedmine.js

Additional rules can be added either to TurndownPluginRedmine.js if they are relevant to Redmine, or as a module in RedmineTurndownService.js.