Skip to content

Commit c2e933c

Browse files
committed
Readme update and small npm package fix
1 parent e85b924 commit c2e933c

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

README.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A VSCode command called `Prettify markdown tables` is also available to format t
2929
### Configurable settings:
3030
- The maximum texth length of a selection/entire document to consider for formatting. Default: 1M chars (limit does not apply from CLI or NPM).
3131
- Additional languages to support formatting for besides `markdown`. See possible configurable values [here](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers). Default: `[ ]`.
32-
- Column spacing to make the columns more spaced out from each other. Default: `0` (no extra spacing).
32+
- Column padding to make the columns more spaced out from each other. Default: `0` (no extra spacing/padding).
3333
- Keyboard shortcut to prettify the currently opened markdown document. Default: <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>M</kbd> (<kbd>CMD</kbd>+<kbd>ALT</kbd>+<kbd>M</kbd> on Mac).
3434

3535
## NPM
@@ -47,12 +47,23 @@ console.log(CliPrettify.prettify(
4747
`hello|world
4848
-|-
4949
foo|bar`));
50-
5150
/* Output:
5251
hello | world
5352
------|------
5453
foo | bar
5554
*/
55+
56+
// specifying a column padding
57+
console.log(CliPrettify.prettify(
58+
`hello|world
59+
-|-
60+
foo|bar`, { columnPadding: 1 }));
61+
/* Output:
62+
hello | world
63+
------ | ------
64+
foo | bar
65+
*/
66+
5667
```
5768

5869
## Docker & CLI
@@ -61,26 +72,26 @@ The core formatting logic is available as a node docker image: `docker pull dark
6172

6273
Formatting files or checking if they're already formatted is also possible from the command line without docker. This requires `node` and `npm` (optionally also `npx`).
6374

64-
| Feature | Docker | CLI |
65-
|--------------------------------------|-------------------------------------------------------------------------------|-------------------------------------------------------------|
66-
| Prettify a file | `docker container run -i darkriszty/prettify-md < input.md` | `npm run --silent prettify-md < input.md` |
67-
| Prettify a file and save the output | `docker container run -i darkriszty/prettify-md < input.md > output.md` | `npm run --silent prettify-md < input.md > output.md` |
68-
| * Check whether a file is prettyfied | `docker container run -i darkriszty/prettify-md --check < input.md` | `npm run --silent check-md < input.md` |
69-
| Use `1` extra space between columns | `docker container run -i darkriszty/prettify-md --columnPadding=1 < input.md` | `npm run --silent prettify-md -- --columnPadding=1 < input.md` |
75+
| Feature | Docker | CLI |
76+
|---------------------------------------|-------------------------------------------------------------------------------|----------------------------------------------------------------|
77+
| Prettify a file | `docker container run -i darkriszty/prettify-md < input.md` | `npm run --silent prettify-md < input.md` |
78+
| Prettify a file and save the output | `docker container run -i darkriszty/prettify-md < input.md > output.md` | `npm run --silent prettify-md < input.md > output.md` |
79+
| Check whether a file is pretty or not | `docker container run -i darkriszty/prettify-md --check < input.md` | `npm run --silent check-md < input.md` |
80+
| Use `1` as column padding | `docker container run -i darkriszty/prettify-md --columnPadding=1 < input.md` | `npm run --silent prettify-md -- --columnPadding=1 < input.md` |
7081

71-
> \* : the check will fail with an exception and return code `1` if the file is not prettyfied.
72-
>
73-
> 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.
74-
> Note: the `--` after the npm run script part is needed for npm to forward the arguments (for instance `--columnPadding=1`) to the actual script.
82+
> Notes:
83+
> * The prettify check (`--check` or `check-md`) will fail with an exception and return code `1` if the file is not prettyfied.
84+
> * 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.
85+
> * The `--` after the npm run script part is needed for npm to forward the arguments (for instance `--columnPadding=1`) to the actual prettyfier script.
86+
> * Optionally, use `npx` to prettify files: `npx markdown-table-prettify < input.md` instead of `npm run --silent prettify-md < input.md`.
7587
7688
### Installation
7789

78-
To access the CLI, the extension can either be used from the Github sources, from the already instaledl VSCode extension or from NPM.
90+
To access the CLI, the extension can either be used from the Github sources, from the already installed VSCode extension or from NPM.
7991

8092
#### Compiling from the source code
8193

82-
- Download the source code.
83-
- Go to the extension directory.
94+
- Clone or download the source code.
8495
- Run `npm install`.
8596
- Run `npm run compile`.
8697

@@ -93,7 +104,7 @@ Locate the installed extension path. The typical location of the installed exten
93104

94105
#### Getting it from NPM
95106

96-
Install the NPM package `npm install -g markdown-table-prettify`. Optionally, use `npx` to prettify files: `npx markdown-table-prettify < input.md` (instead of `npm run --silent prettify-md < input.md`).
107+
Install the NPM package `npm install -g markdown-table-prettify`.
97108

98109
## Known Issues
99110

cli/cliPrettify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class CliPrettify {
4848
new ContentPadCalculator(new PadCalculatorSelector(), " "),
4949
new AlignmentMarkerStrategy(":")
5050
)),
51-
new TableStringWriter(new ValuePaddingProvider(options.columnPadding)),
51+
new TableStringWriter(new ValuePaddingProvider(options?.columnPadding ?? 0)),
5252
[ logger ],
5353
new NoSizeLimitChecker()
5454
),

0 commit comments

Comments
 (0)