tangled
alpha
login
or
join now
eldridge.cam
/
paper-terminal
0
fork
atom
Print Markdown to a paper in your terminal
0
fork
atom
overview
issues
pulls
pipelines
update to clap
eldridge.cam
2 years ago
8dbafae4
9dc77081
+188
-110
3 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
src
main.rs
+171
-92
Cargo.lock
···
33
33
]
34
34
35
35
[[package]]
36
36
-
name = "atty"
37
37
-
version = "0.2.14"
36
36
+
name = "anstream"
37
37
+
version = "0.6.4"
38
38
+
source = "registry+https://github.com/rust-lang/crates.io-index"
39
39
+
checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44"
40
40
+
dependencies = [
41
41
+
"anstyle",
42
42
+
"anstyle-parse",
43
43
+
"anstyle-query",
44
44
+
"anstyle-wincon",
45
45
+
"colorchoice",
46
46
+
"utf8parse",
47
47
+
]
48
48
+
49
49
+
[[package]]
50
50
+
name = "anstyle"
51
51
+
version = "1.0.4"
52
52
+
source = "registry+https://github.com/rust-lang/crates.io-index"
53
53
+
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
54
54
+
55
55
+
[[package]]
56
56
+
name = "anstyle-parse"
57
57
+
version = "0.2.2"
38
58
source = "registry+https://github.com/rust-lang/crates.io-index"
39
39
-
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
59
59
+
checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140"
40
60
dependencies = [
41
41
-
"hermit-abi",
42
42
-
"libc",
43
43
-
"winapi",
61
61
+
"utf8parse",
62
62
+
]
63
63
+
64
64
+
[[package]]
65
65
+
name = "anstyle-query"
66
66
+
version = "1.0.0"
67
67
+
source = "registry+https://github.com/rust-lang/crates.io-index"
68
68
+
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
69
69
+
dependencies = [
70
70
+
"windows-sys",
71
71
+
]
72
72
+
73
73
+
[[package]]
74
74
+
name = "anstyle-wincon"
75
75
+
version = "3.0.1"
76
76
+
source = "registry+https://github.com/rust-lang/crates.io-index"
77
77
+
checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
78
78
+
dependencies = [
79
79
+
"anstyle",
80
80
+
"windows-sys",
44
81
]
45
82
46
83
[[package]]
···
93
130
94
131
[[package]]
95
132
name = "clap"
96
96
-
version = "2.34.0"
133
133
+
version = "4.4.8"
134
134
+
source = "registry+https://github.com/rust-lang/crates.io-index"
135
135
+
checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64"
136
136
+
dependencies = [
137
137
+
"clap_builder",
138
138
+
"clap_derive",
139
139
+
]
140
140
+
141
141
+
[[package]]
142
142
+
name = "clap_builder"
143
143
+
version = "4.4.8"
97
144
source = "registry+https://github.com/rust-lang/crates.io-index"
98
98
-
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
145
145
+
checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc"
99
146
dependencies = [
100
100
-
"ansi_term",
101
101
-
"atty",
102
102
-
"bitflags",
147
147
+
"anstream",
148
148
+
"anstyle",
149
149
+
"clap_lex",
103
150
"strsim",
104
104
-
"textwrap",
105
105
-
"unicode-width",
106
106
-
"vec_map",
107
151
]
108
152
109
153
[[package]]
154
154
+
name = "clap_derive"
155
155
+
version = "4.4.7"
156
156
+
source = "registry+https://github.com/rust-lang/crates.io-index"
157
157
+
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
158
158
+
dependencies = [
159
159
+
"heck",
160
160
+
"proc-macro2",
161
161
+
"quote",
162
162
+
"syn 2.0.39",
163
163
+
]
164
164
+
165
165
+
[[package]]
166
166
+
name = "clap_lex"
167
167
+
version = "0.6.0"
168
168
+
source = "registry+https://github.com/rust-lang/crates.io-index"
169
169
+
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
170
170
+
171
171
+
[[package]]
110
172
name = "color_quant"
111
173
version = "1.1.0"
112
174
source = "registry+https://github.com/rust-lang/crates.io-index"
113
175
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
176
176
+
177
177
+
[[package]]
178
178
+
name = "colorchoice"
179
179
+
version = "1.0.0"
180
180
+
source = "registry+https://github.com/rust-lang/crates.io-index"
181
181
+
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
114
182
115
183
[[package]]
116
184
name = "console"
···
265
333
266
334
[[package]]
267
335
name = "heck"
268
268
-
version = "0.3.3"
336
336
+
version = "0.4.1"
269
337
source = "registry+https://github.com/rust-lang/crates.io-index"
270
270
-
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
271
271
-
dependencies = [
272
272
-
"unicode-segmentation",
273
273
-
]
338
338
+
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
274
339
275
340
[[package]]
276
341
name = "hermit-abi"
···
424
489
dependencies = [
425
490
"ansi_term",
426
491
"cjk",
492
492
+
"clap",
427
493
"console",
428
494
"directories-next",
429
495
"image",
430
496
"pulldown-cmark",
431
431
-
"structopt",
432
497
"syncat-stylesheet",
433
498
"terminal_size",
434
499
"unicode-width",
···
447
512
]
448
513
449
514
[[package]]
450
450
-
name = "proc-macro-error"
451
451
-
version = "1.0.4"
452
452
-
source = "registry+https://github.com/rust-lang/crates.io-index"
453
453
-
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
454
454
-
dependencies = [
455
455
-
"proc-macro-error-attr",
456
456
-
"proc-macro2",
457
457
-
"quote",
458
458
-
"syn",
459
459
-
"version_check",
460
460
-
]
461
461
-
462
462
-
[[package]]
463
463
-
name = "proc-macro-error-attr"
464
464
-
version = "1.0.4"
465
465
-
source = "registry+https://github.com/rust-lang/crates.io-index"
466
466
-
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
467
467
-
dependencies = [
468
468
-
"proc-macro2",
469
469
-
"quote",
470
470
-
"version_check",
471
471
-
]
472
472
-
473
473
-
[[package]]
474
515
name = "proc-macro2"
475
475
-
version = "1.0.40"
516
516
+
version = "1.0.69"
476
517
source = "registry+https://github.com/rust-lang/crates.io-index"
477
477
-
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
518
518
+
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
478
519
dependencies = [
479
520
"unicode-ident",
480
521
]
···
493
534
494
535
[[package]]
495
536
name = "quote"
496
496
-
version = "1.0.20"
537
537
+
version = "1.0.33"
497
538
source = "registry+https://github.com/rust-lang/crates.io-index"
498
498
-
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
539
539
+
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
499
540
dependencies = [
500
541
"proc-macro2",
501
542
]
···
575
616
576
617
[[package]]
577
618
name = "strsim"
578
578
-
version = "0.8.0"
579
579
-
source = "registry+https://github.com/rust-lang/crates.io-index"
580
580
-
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
581
581
-
582
582
-
[[package]]
583
583
-
name = "structopt"
584
584
-
version = "0.3.26"
619
619
+
version = "0.10.0"
585
620
source = "registry+https://github.com/rust-lang/crates.io-index"
586
586
-
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
587
587
-
dependencies = [
588
588
-
"clap",
589
589
-
"lazy_static",
590
590
-
"structopt-derive",
591
591
-
]
621
621
+
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
592
622
593
623
[[package]]
594
594
-
name = "structopt-derive"
595
595
-
version = "0.4.18"
624
624
+
name = "syn"
625
625
+
version = "1.0.98"
596
626
source = "registry+https://github.com/rust-lang/crates.io-index"
597
597
-
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
627
627
+
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
598
628
dependencies = [
599
599
-
"heck",
600
600
-
"proc-macro-error",
601
629
"proc-macro2",
602
630
"quote",
603
603
-
"syn",
631
631
+
"unicode-ident",
604
632
]
605
633
606
634
[[package]]
607
635
name = "syn"
608
608
-
version = "1.0.98"
636
636
+
version = "2.0.39"
609
637
source = "registry+https://github.com/rust-lang/crates.io-index"
610
610
-
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
638
638
+
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
611
639
dependencies = [
612
640
"proc-macro2",
613
641
"quote",
···
616
644
617
645
[[package]]
618
646
name = "syncat-stylesheet"
619
619
-
version = "2.2.1"
647
647
+
version = "3.5.0"
620
648
source = "registry+https://github.com/rust-lang/crates.io-index"
621
621
-
checksum = "2abdfdde201305d60c7f184dde404f6cae02390dda149567b7fca39fe76c21d4"
649
649
+
checksum = "9a0ad46e0dea7c8a1affa928824a3eaf1e24812fb9f91921b00eb2587c63ef29"
622
650
dependencies = [
623
651
"ansi_term",
624
652
"cc",
···
639
667
]
640
668
641
669
[[package]]
642
642
-
name = "textwrap"
643
643
-
version = "0.11.0"
644
644
-
source = "registry+https://github.com/rust-lang/crates.io-index"
645
645
-
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
646
646
-
dependencies = [
647
647
-
"unicode-width",
648
648
-
]
649
649
-
650
650
-
[[package]]
651
670
name = "thiserror"
652
671
version = "1.0.31"
653
672
source = "registry+https://github.com/rust-lang/crates.io-index"
···
664
683
dependencies = [
665
684
"proc-macro2",
666
685
"quote",
667
667
-
"syn",
686
686
+
"syn 1.0.98",
668
687
]
669
688
670
689
[[package]]
···
680
699
681
700
[[package]]
682
701
name = "tree-sitter"
683
683
-
version = "0.19.5"
702
702
+
version = "0.20.10"
684
703
source = "registry+https://github.com/rust-lang/crates.io-index"
685
685
-
checksum = "ad726ec26496bf4c083fff0f43d4eb3a2ad1bba305323af5ff91383c0b6ecac0"
704
704
+
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
686
705
dependencies = [
687
706
"cc",
688
707
"regex",
···
710
729
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
711
730
712
731
[[package]]
713
713
-
name = "unicode-segmentation"
714
714
-
version = "1.9.0"
715
715
-
source = "registry+https://github.com/rust-lang/crates.io-index"
716
716
-
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
717
717
-
718
718
-
[[package]]
719
732
name = "unicode-width"
720
733
version = "0.1.9"
721
734
source = "registry+https://github.com/rust-lang/crates.io-index"
722
735
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
723
736
724
737
[[package]]
725
725
-
name = "vec_map"
726
726
-
version = "0.8.2"
738
738
+
name = "utf8parse"
739
739
+
version = "0.2.1"
727
740
source = "registry+https://github.com/rust-lang/crates.io-index"
728
728
-
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
741
741
+
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
729
742
730
743
[[package]]
731
744
name = "version_check"
···
772
785
version = "0.4.0"
773
786
source = "registry+https://github.com/rust-lang/crates.io-index"
774
787
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
788
788
+
789
789
+
[[package]]
790
790
+
name = "windows-sys"
791
791
+
version = "0.48.0"
792
792
+
source = "registry+https://github.com/rust-lang/crates.io-index"
793
793
+
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
794
794
+
dependencies = [
795
795
+
"windows-targets",
796
796
+
]
797
797
+
798
798
+
[[package]]
799
799
+
name = "windows-targets"
800
800
+
version = "0.48.5"
801
801
+
source = "registry+https://github.com/rust-lang/crates.io-index"
802
802
+
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
803
803
+
dependencies = [
804
804
+
"windows_aarch64_gnullvm",
805
805
+
"windows_aarch64_msvc",
806
806
+
"windows_i686_gnu",
807
807
+
"windows_i686_msvc",
808
808
+
"windows_x86_64_gnu",
809
809
+
"windows_x86_64_gnullvm",
810
810
+
"windows_x86_64_msvc",
811
811
+
]
812
812
+
813
813
+
[[package]]
814
814
+
name = "windows_aarch64_gnullvm"
815
815
+
version = "0.48.5"
816
816
+
source = "registry+https://github.com/rust-lang/crates.io-index"
817
817
+
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
818
818
+
819
819
+
[[package]]
820
820
+
name = "windows_aarch64_msvc"
821
821
+
version = "0.48.5"
822
822
+
source = "registry+https://github.com/rust-lang/crates.io-index"
823
823
+
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
824
824
+
825
825
+
[[package]]
826
826
+
name = "windows_i686_gnu"
827
827
+
version = "0.48.5"
828
828
+
source = "registry+https://github.com/rust-lang/crates.io-index"
829
829
+
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
830
830
+
831
831
+
[[package]]
832
832
+
name = "windows_i686_msvc"
833
833
+
version = "0.48.5"
834
834
+
source = "registry+https://github.com/rust-lang/crates.io-index"
835
835
+
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
836
836
+
837
837
+
[[package]]
838
838
+
name = "windows_x86_64_gnu"
839
839
+
version = "0.48.5"
840
840
+
source = "registry+https://github.com/rust-lang/crates.io-index"
841
841
+
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
842
842
+
843
843
+
[[package]]
844
844
+
name = "windows_x86_64_gnullvm"
845
845
+
version = "0.48.5"
846
846
+
source = "registry+https://github.com/rust-lang/crates.io-index"
847
847
+
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
848
848
+
849
849
+
[[package]]
850
850
+
name = "windows_x86_64_msvc"
851
851
+
version = "0.48.5"
852
852
+
source = "registry+https://github.com/rust-lang/crates.io-index"
853
853
+
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+2
-2
Cargo.toml
···
17
17
path = "src/main.rs"
18
18
19
19
[dependencies]
20
20
-
structopt = "0.3"
20
20
+
clap = { version = "4.4", features = ["derive"] }
21
21
terminal_size = "0.1"
22
22
pulldown-cmark = "0.8"
23
23
ansi_term = "0.12"
24
24
image = "0.23"
25
25
console = { version = "0.14", features = ["unicode-width"] }
26
26
directories-next = "2.0"
27
27
-
syncat-stylesheet = { version = "2.1.4", features = ["ansi_term"] }
27
27
+
syncat-stylesheet = { version = "3.5.0", features = ["ansi_term"] }
28
28
unicode-width = "0.1"
29
29
cjk = "0.2"
+15
-16
src/main.rs
···
1
1
use ansi_term::Style;
2
2
+
use clap::Parser as _;
2
3
use console::strip_ansi_codes;
3
4
use pulldown_cmark::{Options, Parser};
4
5
use std::convert::TryInto;
5
6
use std::fs;
6
7
use std::io::{self, Read};
7
8
use std::path::PathBuf;
8
8
-
use structopt::StructOpt;
9
9
use syncat_stylesheet::Stylesheet;
10
10
use terminal_size::{terminal_size, Width};
11
11
···
21
21
use words::Words;
22
22
23
23
/// Prints papers in your terminal
24
24
-
#[derive(StructOpt, Debug)]
25
25
-
#[structopt(name = "paper")]
26
26
-
#[structopt(rename_all = "kebab-case")]
27
27
-
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
24
24
+
#[derive(clap::Parser, Debug)]
25
25
+
#[clap(name = "paper")]
26
26
+
#[clap(rename_all = "kebab-case")]
28
27
pub struct Opts {
29
28
/// Margin (shortcut for horizontal and vertical margin set to the same value)
30
30
-
#[structopt(short, long, default_value = "6")]
29
29
+
#[structopt(short = 'm', long, default_value = "6")]
31
30
pub margin: usize,
32
31
33
32
/// Horizontal margin (overrides --margin)
34
34
-
#[structopt(short, long)]
33
33
+
#[structopt(long)]
35
34
pub h_margin: Option<usize>,
36
35
37
36
/// Vertical margin (overrides --margin)
38
38
-
#[structopt(short, long)]
37
37
+
#[structopt(long)]
39
38
pub v_margin: Option<usize>,
40
39
41
40
/// The width of the paper (including the space used for the margin)
42
42
-
#[structopt(short, long, default_value = "92")]
41
41
+
#[structopt(short = 'w', long, default_value = "92")]
43
42
pub width: usize,
44
43
45
44
/// Don't parse as Markdown, just render the plain text on a paper
46
46
-
#[structopt(short, long)]
45
45
+
#[structopt(short = 'p', long)]
47
46
pub plain: bool,
48
47
49
48
/// The length to consider tabs as.
···
51
50
pub tab_length: usize,
52
51
53
52
/// Hide link URLs
54
54
-
#[structopt(short = "u", long)]
53
53
+
#[structopt(short = 'U', long)]
55
54
pub hide_urls: bool,
56
55
57
56
/// Disable drawing images
58
58
-
#[structopt(short = "i", long)]
57
57
+
#[structopt(short = 'I', long)]
59
58
pub no_images: bool,
60
59
61
60
/// Position paper on the left edge of the terminal, instead of centred.
62
62
-
#[structopt(short = "l", long)]
61
61
+
#[structopt(short = 'l', long)]
63
62
pub left: bool,
64
63
65
64
/// Position paper on the right edge of the terminal, instead of centred.
66
66
-
#[structopt(short = "r", long)]
65
65
+
#[structopt(short = 'r', long)]
67
66
pub right: bool,
68
67
69
68
/// Use syncat to highlight code blocks. Requires you have syncat installed.
···
75
74
pub dev: bool,
76
75
77
76
/// Files to print
78
78
-
#[structopt(name = "FILE", parse(from_os_str))]
77
77
+
#[structopt(name = "FILE")]
79
78
pub files: Vec<PathBuf>,
80
79
}
81
80
···
235
234
}
236
235
237
236
fn main() {
238
238
-
let opts = Opts::from_args();
237
237
+
let opts = Opts::parse();
239
238
240
239
if opts.files.is_empty() {
241
240
let mut string = String::new();