You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

prettify-markdown

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettify-markdown - npm Package Compare versions

Comparing version
0.1.0
to
0.1.1
+57
README.md
# prettify-markdown [![NPM version](https://badge.fury.io/js/prettify-markdown.svg)](http://badge.fury.io/js/prettify-markdown)
> Prettify, format or beautify your markdown. Whatever you want to call it, this does that. Used on hundreds of projects by verb.
## Install with [npm](npmjs.org)
```bash
npm i prettify-markdown --save
```
Currently this does very basic, naive formatting focusing on headings and whitespace control.
This was just externalized from [verb], where this case was used on hundreds of projects to format API documentation. As basic as it is, this has gotten the job done pretty consistently.
## Usage
```js
var prettify = require('prettify-markdown');
```
## Related projects
* [markdown-toc](https://github.com/jonschlinkert/markdown-toc): Generate a markdown TOC (table of contents) with Remarkable.
* [remarkable](https://github.com/jonschlinkert/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://github.com/jonschlinkert/remarkable)
## Running tests
Install dev dependencies:
```bash
npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/prettify-markdown/issues)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 26, 2015._
<!-- reflinks generated by verb-reflinks plugin -->
[assemble]: http://assemble.io
[template]: https://github.com/jonschlinkert/template
[verb]: https://github.com/assemble/verb
+43
-2

@@ -16,5 +16,11 @@ /*!

}
var obj = removeBlocks(str);
str = obj.str;
str = str.split(/(?:\r\n|\n){3,}/).join('\n\n');
str = headings(str);
str = bolded(str);
str = addBlocks(str, obj);
return str.trim();

@@ -24,3 +30,3 @@ };

function headings(str) {
var re = /^(#{1,6})\s+([^\n]+)\s+/g;
var re = /^(#{1,6})\s+([^\n]+)\s+/gm;
return str.replace(re, function (match, $1, $2) {

@@ -32,3 +38,3 @@ return $1 + ' ' + $2 + '\n\n';

function bolded(str) {
var re = /^\s*\*\*([^\n]+)\*\*(?=\n)\s+/g;
var re = /^\s*\*\*([^\n]+)\*\*(?=\n)\s+/gm;
return str.replace(re, function (match, $1) {

@@ -38,1 +44,36 @@ return '\n**' + $1 + '**\n\n';

}
function removeBlocks(str) {
var codeBlocks = gfm(str);
var len = codeBlocks.length;
var stash = {}, i = 0;
if (len > 0) {
while (len--) {
var key = '__BLOCK' + (i) + '__';
var cur = codeBlocks[i++];
stash[key] = cur;
str = str.split(cur.block).join(key);
}
}
return {str: str, stash: stash};
}
function addBlocks(str, obj) {
var stash = obj.stash;
for (var key in stash) {
var val = stash[key];
if (stash.hasOwnProperty(key)) {
var re = new RegExp('\\s+' + key + '\\s+');
var block = '\n\n';
block += '```' + val.lang + '\n';
block += val.code + '\n';
block += '```\n\n';
str = str.split(re).join(block);
}
}
return str;
}
+2
-2
{
"name": "prettify-markdown",
"description": "Prettify, format or beautify your markdown. Whatever you want to call it, this does that. Used on hundreds of projects by verb.",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/jonschlinkert/prettify-markdown",

@@ -50,2 +50,2 @@ "author": {

}
}
}