Skip to content

ThanhTuan1695/markdown-expands-tab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-expands-tab

A markdown-it plugin to replace leading tabs with spaces in code blocks

What it does

  • Replaces leading tabs with spaces in fenced code blocks
  • Nothing else

Why is this useful?

Say you have tab-indented code in a markdown file and you want the rendered code to take up less visual space horizontally. This plugin will help. If you're not in that situation, then this plugin probably isn't for you.

Installation

npm install markdown-expands-tab

Usage

Use it the same as a normal markdown-it plugin:

var md = require('markdown-it');
var expandTabs = require('markdown-expands-tab');

var parser = md().use(expandTabs);

var result = parser.render(...); // markdown string containing tab-indented code blocks

The default behavior is to convert leading tabs into two spaces each. You can choose an alternate tab width thusly:

var parser = md().use(expandTabs, {tabWidth: 4});

Tests

npm install
npm test

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published