Skip to content

Commit f3e39af

Browse files
committed
Add support to package as npm
1 parent 307b4b0 commit f3e39af

6 files changed

Lines changed: 233 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to the `markdowntableprettify` extension will be documented
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
8+
### Added
9+
- Issue #49: NPM package support.
10+
11+
## 3.2.1 - 2020-01-01
12+
### Fixed
13+
- Issue #50: Dockerfile improvements.
814

915
## 3.2.0 - 2020-12-14
1016
### Added

README.md

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,66 @@
1-
# Markdown table prettifier extension for Visual Studio Code
1+
# Markdown table prettifier
22

33
[![Test Status](https://github.com/darkriszty/MarkdownTablePrettify-VSCodeExt/workflows/Tests/badge.svg)](https://github.com/darkriszty/MarkdownTablePrettify-VSCodeExt/actions)
4+
[![Visual Studio Code extension](https://img.shields.io/visual-studio-marketplace/v/darkriszty.markdown-table-prettify?color=success&label=VSCode)](https://marketplace.visualstudio.com/items?itemName=darkriszty.markdown-table-prettify)
5+
[![Docker image](https://img.shields.io/docker/v/darkriszty/prettify-md?color=success&label=Docker)](https://hub.docker.com/r/darkriszty/prettify-md/tags?page=1&ordering=last_updated)
6+
[![npm package](https://img.shields.io/npm/v/markdown-table-prettify?color=success)](https://hub.docker.com/r/darkriszty/prettify-md/tags?page=1&ordering=last_updated)
47

58
Makes tables more readable for humans. Compatible with the Markdown writer plugin's table formatter feature in Atom.
69

7-
## Features
10+
## Feature highlights
811

912
- Remove redundant ending table border if the beginning has no border, so the table _will not end_ with "|".
1013
- Create missing ending table border if the beginning already has a border, so the table _will end_ with "|".
1114
- Save space by not right-padding the last column if the table has no border.
1215
- Support empty columns inside tables.
1316
- Support column alignment options with ":".
14-
- CLI and docker support to prettify files.
17+
- Find and format multiple tables.
18+
- Support indented tables.
19+
20+
## Visual Studio Code
1521

1622
![feature X](assets/animation.gif)
1723

18-
### CLI formatting
24+
The extension is available for markdown language mode. It can either prettify a selection (`Format Selection`) or the entire document (`Format Document`).
25+
A VSCode command called `Prettify markdown tables` is also available to format the currently opened document.
26+
27+
Configurable settings:
28+
- The maximum texth length of a selection/entire document to consider for formatting. Defaults to 1M chars. (limit does not apply from CLI or NPM).
29+
- Keyboard shortcut to prettify the currently opened markdown document. Default: CTRL+ALT+M (CMD+ALT+M on Mac).
30+
31+
## NPM
32+
33+
The core formatting logic is available as an NPM package: `npm install --save markdown-table-prettify`. The Typescript code is compiled down to ES5 and shipped inside the package.
34+
35+
It currently exposes the entry point also used by the _CLI_. It can be used from regular NodeJS or web apps:
36+
37+
```JS
38+
import { CliPrettify } from 'markdown-table-prettify';
39+
// or
40+
const { CliPrettify } = require('markdown-table-prettify');
41+
42+
console.log(CliPrettify.prettify(
43+
`hello|world
44+
-|-
45+
foo|bar`));
46+
47+
/* Output:
48+
hello | world
49+
------|------
50+
foo | bar
51+
*/
52+
```
53+
54+
## Docker
55+
56+
The core formatting logic is available as a node docker image: `docker pull darkriszty/prettify-md`.
57+
58+
Available features from docker:
59+
- To prettify a file: `docker container run -i darkriszty/prettify-md < input.md`.
60+
- To prettify a file and save the output: `docker container run -i darkriszty/prettify-md < input.md > output.md`.
61+
- To check whether a file is prettyfied or not: `docker container run -i darkriszty/prettify-md --check < input.md`. This will fail with an exception and return code `1` if the file is not prettyfied.
62+
63+
## CLI
1964

2065
Formatting files or checking if they're already formatted is possible from the command line. This requires `node` and `npm`.
2166

@@ -37,24 +82,6 @@ Available features from the command line:
3782

3883
> Note: the `--silent` switch sets the npm log level to silent, which is useful to hide the executed file name and concentrate on the actual output.
3984
40-
### Formatting with docker
41-
42-
The core formatting logic of the extension is also available as a node docker image: `docker pull darkriszty/prettify-md`.
43-
44-
Available features from docker:
45-
- To prettify a file: `docker container run -i darkriszty/prettify-md < input.md`.
46-
- To prettify a file and save the output: `docker container run -i darkriszty/prettify-md < input.md > output.md`.
47-
- To check whether a file is prettyfied or not: `docker container run -i darkriszty/prettify-md --check < input.md`. This will fail with an exception and return code `1` if the file is not prettyfied.
48-
49-
## Extension Settings
50-
51-
The extension is available for markdown language mode. It can either prettify a selection (`Format Selection`) or the entire document (`Format Document`).
52-
A VSCode command called `Prettify markdown tables` is also available to format the currently opened document.
53-
54-
Configurable settings:
55-
- The maximum texth length of a selection/entire document to consider for formatting. Defaults to 1M chars. There is no limit when running from the command line.
56-
- Keyboard shortcut to prettify the currently opened markdown document. Default: CTRL+ALT+M (CMD+ALT+M on Mac).
57-
5885
## Known Issues
5986

6087
- Tables with mixed character widths (eg: CJK) are not always properly formatted (issue #4).

gulpfile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
var gulp = require("gulp");
2+
var merge = require("gulp-merge-json");
23

34
gulp.task("copy-systemTest-resources", function() {
45
return gulp
56
.src("test/systemTests/resources/*")
67
.pipe(gulp.dest("out/test/systemTests/resources"));
7-
});
8+
});
9+
10+
gulp.task("merge-packagejson-for-npm-dist", function () {
11+
return gulp.src("package.*json")
12+
.pipe(merge({fileName: "package.json"}))
13+
.pipe(gulp.dest("out"));
14+
});

package-lock.json

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)