Skip to content

Commit 3afafd0

Browse files
committed
Added CLI
1 parent f0a988a commit 3afafd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3465
-69
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: NMD Cargo Build & Test
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Build
20+
run: cargo build --verbose
21+
- name: Run tests
22+
run: cargo test --verbose

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Cargo.lock
1616
perf.data
1717
perf.data.old
1818
flamegraph.svg
19-
profile.json
19+
./profile.json

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
"./Cargo.toml",
55
"./Cargo.toml"
66
],
7-
"rust-analyzer.showUnlinkedFileNotification": false
7+
"rust-analyzer.showUnlinkedFileNotification": false,
8+
"cSpell.words": [
9+
"nuid"
10+
]
811
}

Cargo.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[package]
2+
name = "nmd"
3+
version = "1.3.0"
4+
authors = ["Nicola Ricciardi"]
5+
edition = "2021"
6+
description = "Official NMD CLI and compiler"
7+
readme = "README.md"
8+
repository = "https://github.com/nricciardi/nmd"
9+
license-file = "LICENSE"
10+
keywords = ["compiler", "nmd", "markdown"]
11+
exclude = [
12+
"test-resources/*",
13+
"logo/*",
14+
"docs/*"
15+
]
16+
17+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
18+
19+
[dependencies]
20+
clap = "4.4.18"
21+
env_logger = "0.10.1"
22+
getset = "0.1.2"
23+
log = "0.4.20"
24+
notify = "6.1.1"
25+
once_cell = "1.19.0"
26+
rayon = "1.8.0"
27+
regex = "1.10.2"
28+
reqwest = { version = "0.11.24", features = ["blocking"] }
29+
serde = { version = "1.0.195", features = ["derive"] }
30+
serde_json = "1.0.113"
31+
serde_yaml = "0.9.31"
32+
simple_logger = "4.3.3"
33+
thiserror = "1.0.50"
34+
url = "2.5.0"
35+
tokio = { version = "1", features = ["full"] }
36+
warp = "0.3"
37+
chrono = "0.4.38"
38+
nmd-core = "0.40.0"
39+
40+
41+
[profile.profiling]
42+
inherits = "release"
43+
debug = true

DEVELOP.md

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,6 @@
44

55
nothing
66

7-
### Features done
8-
9-
- [x] Use file name instead of absolute path in dossier configuration
10-
- [x] Other sections in dossier configuration to manage all options
11-
- [x] Local math (no CDN)
12-
- [x] List
13-
- [x] List creation check
14-
- [x] Link with identifier
15-
- [x] Link to chapters
16-
- [x] Quote
17-
- [x] Image caption
18-
- [x] Image URL fix meta-characters
19-
- [x] Multiple image in a single row
20-
- [x] Set image dimensions
21-
- [x] Image compression
22-
- [x] Image in dossier: default path to `assets/images`
23-
- [x] Parse image caption
24-
- [x] Focus block
25-
- [x] Light base page style
26-
- [x] Embedded style
27-
- [x] Embedded chapter style
28-
- [x] Custom style files
29-
- [x] Tables
30-
- [x] Embedded Greek letters
31-
- [x] Fix single list item
32-
- [x] Todo modifier with only `todo` or `TODO`
33-
- [x] Todo modifier with text between `TODO:` and `:TODO`
34-
- [x] Relative header (e.g. `#+` to indicate precedent header level + 1, `#=` to indicate same header level of precedente header)
35-
- [x] Short image modifier (without alt)
36-
- [x] `nmd dossier add` auto-add `.nmd`
37-
- [x] `nmd dossier add` accept more than one file
38-
- [x] Escape
39-
- [x] Metadata
40-
- [x] Reference
41-
- [x] Table of contents without page numbers
42-
- [x] Bibliography
43-
- [x] Compile only modified chapters in watcher mode
44-
- [x] Web server to refresh compiled output
45-
467
### Planned Features
478

48-
- [ ] All modifiers
49-
- [ ] `* words *`
50-
- [x] Use `getset` crate
51-
- [ ] embed_remote_image
52-
- [ ] Possibility to use a different dossier configuration name
53-
- [ ] PDF compile format
54-
- [x] Vintage style (typewriter)
55-
- [x] Dark style
56-
- [ ] Run code
57-
- [ ] Video
58-
- [x] Scientific style
59-
- [ ] Linkify (convert URL-like strings in links)
60-
- [x] Fast draft (prevent to parse time consuming parts)
61-
- [ ] Dynamics addons (e.g. katex iff math is used)
629
- [ ] Watcher mode for single file compilation
63-
- [ ] Split CLI lib from compiler
64-
- [x] Compile only a subset of documents
65-
- [ ] Paper format support (A3, A5, ...)
66-
- [x] MD to NMD converter
67-
- [x] Include all .nmd file in running directory as default option in dossier configuration
68-
- [x] Compile single files
69-
- [ ] Table of contents with page numbers
70-
- [ ] Select position of ToC and Bibliography
71-
- [ ] Cover page
72-
- [ ] VS Code extension (https://dev.to/salesforceeng/how-to-build-a-vs-code-extension-for-markdown-preview-using-remark-processor-1169)

README.md

Lines changed: 121 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
![Logo](logo/logo.png)
22

3+
4+
[![License](https://img.shields.io/badge/license-GPL3-green.svg)](LICENSE)
5+
[![Version](https://img.shields.io/badge/version-v1.3.0-blue.svg)](CHANGELOG.md)
6+
37
# New MarkDown
48

59
**New way to write in markdown**
@@ -57,18 +61,131 @@ Why stick to Markdown when you can be cool using **NMD**?
5761

5862
You can find the current NMD's syntax to build nmd documents go to this [link](https://github.com/nricciardi/nmd-core/blob/main/NMD.md).
5963

60-
## NMD command line interface
6164

62-
You can download last release of **NMD command line interface** [here](https://github.com/nricciardi/nmd-cli/releases) or download it through [Cargo](https://github.com/rust-lang/cargo):
65+
## NMD CLI
66+
67+
### Getting Started
68+
69+
Do you want **migrate from Markdown to New Markdown** easily and quickly? Read [how to do that](#markdown-to-new-markdown) using CLI!
70+
71+
### TL;DR
6372

6473
```shell
6574
cargo install nmd
75+
76+
nmd generate dossier -p dossier/input/path -f -w
77+
78+
nmd dossier -p dossier/input/path add -d new-document.nmd
79+
80+
nmd build -i input/path
81+
```
82+
83+
### Installation
84+
85+
You can install NMD using Cargo or downloading last release from Github.
86+
87+
```shell
88+
cargo install nmd
89+
```
90+
91+
### Commands
92+
93+
#### Generate a new dossier
94+
95+
To **generate a new dossier** you can use the following command:
96+
97+
```shell
98+
nmd generate dossier -p dossier/input/path
99+
```
100+
101+
There are many *flags* that you can use in combination with `generate dossier`. For example, if you want *force* the generation you can use `-f`, or if you want a *welcome page* you can use `-w`.
102+
103+
```shell
104+
nmd generate dossier -p dossier/input/path -f -w
105+
```
106+
107+
The Git support is planned, but not implemented yet. You can only add `.gitkeep` files in assets directories using `-k`.
108+
109+
`-n` permits to specify dossier name.
110+
111+
##### Markdown to New Markdown
112+
113+
You can easily convert a standard Markdown file in a New Markdown dossier using `--from-md <md-file-path>` option.
114+
115+
##### Add a new document
116+
117+
To **add a new document** you can use the following command:
118+
119+
```shell
120+
nmd dossier -p dossier/input/path add -d new-document.nmd
121+
```
122+
123+
If the document name doesn't have `nmd` extension, it will be added automatically.
124+
125+
You can add more than one document at the same time:
126+
127+
```shell
128+
nmd dossier -p dossier/input/path add -d new-document-1.nmd -d new-document-2.nmd -d new-document-3.nmd
129+
```
130+
131+
##### Reset dossier configuration
132+
133+
```shell
134+
nmd dossier -p dossier/input/path reset [ -p ]
135+
```
136+
137+
`-p` reset flag to preserve documents list.
138+
139+
#### Build
140+
141+
You can build a dossier or a single file through `build` command.
142+
143+
The only mandatory option is the input path. It can be a path to a directory (dossier) or a file.
144+
145+
```shell
146+
nmd build -i input/path
147+
```
148+
149+
`compile` command has a lot of options. You could specify the output format using `-f <format>` (e.g. `html`, which is the default), the output path with `-o <output-path>` or the theme using `-t <theme>`. The available themes are:
150+
151+
- `light`
152+
- `dark`
153+
- `vintage`
154+
- `scientific`
155+
- `none`
156+
157+
158+
```shell
159+
nmd compile -f html dossier -i dossier/input/path -o artifact/output/path
160+
```
161+
162+
Moreover, if you watch dossier files and compile them if something changes, you should use watcher mode (`-w` option). Watcher mode compile dossier if any change is captured. Changes are captured only if a minimum time is elapsed. To set minimum time use `--watcher-time` option.
163+
164+
`--fast-draft` to create a fast draft of dossier, generally compiler takes less time to generate it.
165+
166+
`--parallelization` to parallelize work (default is single thread).
167+
168+
`-s <document1> -s <documentN>` to compile only a subset of documents in dossier configuration list.
169+
170+
In the end, if you are writing in NMD and you want a preview, you could compile with `-p` option. `-p` renders a preview in a web server on `127.0.0.1:1234` (`--preview-scraping-interval <interval>` to set client scraping interval in *milliseconds*).
171+
172+
`--embed-local-image`, `--embed-remote-image`, `--strict-image-src-check` and `--embed-local-image` to manage images parsing.
173+
174+
You can use `--nuid` to add *NUID*.
175+
176+
#### Analyze
177+
178+
You could want analyze a dossier or a document before build it. `analyze` command print on `stdout` the corresponding JSON.
179+
180+
```shell
181+
nmd analyze -i input/path
66182
```
67183

68-
## NMD x VS Code
184+
You can use `--nuid` to add *NUID* or `--pretty` to print pretty formatted JSON.
69185

70-
You can use the official [NMD x VS Code](https://github.com/nricciardi/nmd-vscode) extension!
186+
## Develop
71187

188+
Develop [check list](DEVELOP.md)
72189

73190
## Author
74191

build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
rustup update
4+
5+
cargo test --verbose
6+
7+
cargo build --release --target x86_64-unknown-linux-gnu
8+
9+
cargo build --release --target x86_64-pc-windows-gnu

0 commit comments

Comments
 (0)