Print Markdown to a paper in your terminal

update to clap

+188 -110
+171 -92
Cargo.lock
··· 33 33 ] 34 34 35 35 [[package]] 36 - name = "atty" 37 - version = "0.2.14" 36 + name = "anstream" 37 + version = "0.6.4" 38 + source = "registry+https://github.com/rust-lang/crates.io-index" 39 + checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" 40 + dependencies = [ 41 + "anstyle", 42 + "anstyle-parse", 43 + "anstyle-query", 44 + "anstyle-wincon", 45 + "colorchoice", 46 + "utf8parse", 47 + ] 48 + 49 + [[package]] 50 + name = "anstyle" 51 + version = "1.0.4" 52 + source = "registry+https://github.com/rust-lang/crates.io-index" 53 + checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" 54 + 55 + [[package]] 56 + name = "anstyle-parse" 57 + version = "0.2.2" 38 58 source = "registry+https://github.com/rust-lang/crates.io-index" 39 - checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 59 + checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" 40 60 dependencies = [ 41 - "hermit-abi", 42 - "libc", 43 - "winapi", 61 + "utf8parse", 62 + ] 63 + 64 + [[package]] 65 + name = "anstyle-query" 66 + version = "1.0.0" 67 + source = "registry+https://github.com/rust-lang/crates.io-index" 68 + checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" 69 + dependencies = [ 70 + "windows-sys", 71 + ] 72 + 73 + [[package]] 74 + name = "anstyle-wincon" 75 + version = "3.0.1" 76 + source = "registry+https://github.com/rust-lang/crates.io-index" 77 + checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" 78 + dependencies = [ 79 + "anstyle", 80 + "windows-sys", 44 81 ] 45 82 46 83 [[package]] ··· 93 130 94 131 [[package]] 95 132 name = "clap" 96 - version = "2.34.0" 133 + version = "4.4.8" 134 + source = "registry+https://github.com/rust-lang/crates.io-index" 135 + checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" 136 + dependencies = [ 137 + "clap_builder", 138 + "clap_derive", 139 + ] 140 + 141 + [[package]] 142 + name = "clap_builder" 143 + version = "4.4.8" 97 144 source = "registry+https://github.com/rust-lang/crates.io-index" 98 - checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" 145 + checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" 99 146 dependencies = [ 100 - "ansi_term", 101 - "atty", 102 - "bitflags", 147 + "anstream", 148 + "anstyle", 149 + "clap_lex", 103 150 "strsim", 104 - "textwrap", 105 - "unicode-width", 106 - "vec_map", 107 151 ] 108 152 109 153 [[package]] 154 + name = "clap_derive" 155 + version = "4.4.7" 156 + source = "registry+https://github.com/rust-lang/crates.io-index" 157 + checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" 158 + dependencies = [ 159 + "heck", 160 + "proc-macro2", 161 + "quote", 162 + "syn 2.0.39", 163 + ] 164 + 165 + [[package]] 166 + name = "clap_lex" 167 + version = "0.6.0" 168 + source = "registry+https://github.com/rust-lang/crates.io-index" 169 + checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" 170 + 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 + 177 + [[package]] 178 + name = "colorchoice" 179 + version = "1.0.0" 180 + source = "registry+https://github.com/rust-lang/crates.io-index" 181 + checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 114 182 115 183 [[package]] 116 184 name = "console" ··· 265 333 266 334 [[package]] 267 335 name = "heck" 268 - version = "0.3.3" 336 + version = "0.4.1" 269 337 source = "registry+https://github.com/rust-lang/crates.io-index" 270 - checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 271 - dependencies = [ 272 - "unicode-segmentation", 273 - ] 338 + checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 274 339 275 340 [[package]] 276 341 name = "hermit-abi" ··· 424 489 dependencies = [ 425 490 "ansi_term", 426 491 "cjk", 492 + "clap", 427 493 "console", 428 494 "directories-next", 429 495 "image", 430 496 "pulldown-cmark", 431 - "structopt", 432 497 "syncat-stylesheet", 433 498 "terminal_size", 434 499 "unicode-width", ··· 447 512 ] 448 513 449 514 [[package]] 450 - name = "proc-macro-error" 451 - version = "1.0.4" 452 - source = "registry+https://github.com/rust-lang/crates.io-index" 453 - checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 454 - dependencies = [ 455 - "proc-macro-error-attr", 456 - "proc-macro2", 457 - "quote", 458 - "syn", 459 - "version_check", 460 - ] 461 - 462 - [[package]] 463 - name = "proc-macro-error-attr" 464 - version = "1.0.4" 465 - source = "registry+https://github.com/rust-lang/crates.io-index" 466 - checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 467 - dependencies = [ 468 - "proc-macro2", 469 - "quote", 470 - "version_check", 471 - ] 472 - 473 - [[package]] 474 515 name = "proc-macro2" 475 - version = "1.0.40" 516 + version = "1.0.69" 476 517 source = "registry+https://github.com/rust-lang/crates.io-index" 477 - checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" 518 + checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" 478 519 dependencies = [ 479 520 "unicode-ident", 480 521 ] ··· 493 534 494 535 [[package]] 495 536 name = "quote" 496 - version = "1.0.20" 537 + version = "1.0.33" 497 538 source = "registry+https://github.com/rust-lang/crates.io-index" 498 - checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" 539 + checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" 499 540 dependencies = [ 500 541 "proc-macro2", 501 542 ] ··· 575 616 576 617 [[package]] 577 618 name = "strsim" 578 - version = "0.8.0" 579 - source = "registry+https://github.com/rust-lang/crates.io-index" 580 - checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 581 - 582 - [[package]] 583 - name = "structopt" 584 - version = "0.3.26" 619 + version = "0.10.0" 585 620 source = "registry+https://github.com/rust-lang/crates.io-index" 586 - checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" 587 - dependencies = [ 588 - "clap", 589 - "lazy_static", 590 - "structopt-derive", 591 - ] 621 + checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 592 622 593 623 [[package]] 594 - name = "structopt-derive" 595 - version = "0.4.18" 624 + name = "syn" 625 + version = "1.0.98" 596 626 source = "registry+https://github.com/rust-lang/crates.io-index" 597 - checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" 627 + checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 598 628 dependencies = [ 599 - "heck", 600 - "proc-macro-error", 601 629 "proc-macro2", 602 630 "quote", 603 - "syn", 631 + "unicode-ident", 604 632 ] 605 633 606 634 [[package]] 607 635 name = "syn" 608 - version = "1.0.98" 636 + version = "2.0.39" 609 637 source = "registry+https://github.com/rust-lang/crates.io-index" 610 - checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" 638 + checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" 611 639 dependencies = [ 612 640 "proc-macro2", 613 641 "quote", ··· 616 644 617 645 [[package]] 618 646 name = "syncat-stylesheet" 619 - version = "2.2.1" 647 + version = "3.5.0" 620 648 source = "registry+https://github.com/rust-lang/crates.io-index" 621 - checksum = "2abdfdde201305d60c7f184dde404f6cae02390dda149567b7fca39fe76c21d4" 649 + checksum = "9a0ad46e0dea7c8a1affa928824a3eaf1e24812fb9f91921b00eb2587c63ef29" 622 650 dependencies = [ 623 651 "ansi_term", 624 652 "cc", ··· 639 667 ] 640 668 641 669 [[package]] 642 - name = "textwrap" 643 - version = "0.11.0" 644 - source = "registry+https://github.com/rust-lang/crates.io-index" 645 - checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 646 - dependencies = [ 647 - "unicode-width", 648 - ] 649 - 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 - "syn", 686 + "syn 1.0.98", 668 687 ] 669 688 670 689 [[package]] ··· 680 699 681 700 [[package]] 682 701 name = "tree-sitter" 683 - version = "0.19.5" 702 + version = "0.20.10" 684 703 source = "registry+https://github.com/rust-lang/crates.io-index" 685 - checksum = "ad726ec26496bf4c083fff0f43d4eb3a2ad1bba305323af5ff91383c0b6ecac0" 704 + checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d" 686 705 dependencies = [ 687 706 "cc", 688 707 "regex", ··· 710 729 checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" 711 730 712 731 [[package]] 713 - name = "unicode-segmentation" 714 - version = "1.9.0" 715 - source = "registry+https://github.com/rust-lang/crates.io-index" 716 - checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" 717 - 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 - name = "vec_map" 726 - version = "0.8.2" 738 + name = "utf8parse" 739 + version = "0.2.1" 727 740 source = "registry+https://github.com/rust-lang/crates.io-index" 728 - checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 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 + 789 + [[package]] 790 + name = "windows-sys" 791 + version = "0.48.0" 792 + source = "registry+https://github.com/rust-lang/crates.io-index" 793 + checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 794 + dependencies = [ 795 + "windows-targets", 796 + ] 797 + 798 + [[package]] 799 + name = "windows-targets" 800 + version = "0.48.5" 801 + source = "registry+https://github.com/rust-lang/crates.io-index" 802 + checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 803 + dependencies = [ 804 + "windows_aarch64_gnullvm", 805 + "windows_aarch64_msvc", 806 + "windows_i686_gnu", 807 + "windows_i686_msvc", 808 + "windows_x86_64_gnu", 809 + "windows_x86_64_gnullvm", 810 + "windows_x86_64_msvc", 811 + ] 812 + 813 + [[package]] 814 + name = "windows_aarch64_gnullvm" 815 + version = "0.48.5" 816 + source = "registry+https://github.com/rust-lang/crates.io-index" 817 + checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 818 + 819 + [[package]] 820 + name = "windows_aarch64_msvc" 821 + version = "0.48.5" 822 + source = "registry+https://github.com/rust-lang/crates.io-index" 823 + checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 824 + 825 + [[package]] 826 + name = "windows_i686_gnu" 827 + version = "0.48.5" 828 + source = "registry+https://github.com/rust-lang/crates.io-index" 829 + checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 830 + 831 + [[package]] 832 + name = "windows_i686_msvc" 833 + version = "0.48.5" 834 + source = "registry+https://github.com/rust-lang/crates.io-index" 835 + checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 836 + 837 + [[package]] 838 + name = "windows_x86_64_gnu" 839 + version = "0.48.5" 840 + source = "registry+https://github.com/rust-lang/crates.io-index" 841 + checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 842 + 843 + [[package]] 844 + name = "windows_x86_64_gnullvm" 845 + version = "0.48.5" 846 + source = "registry+https://github.com/rust-lang/crates.io-index" 847 + checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 848 + 849 + [[package]] 850 + name = "windows_x86_64_msvc" 851 + version = "0.48.5" 852 + source = "registry+https://github.com/rust-lang/crates.io-index" 853 + checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
+2 -2
Cargo.toml
··· 17 17 path = "src/main.rs" 18 18 19 19 [dependencies] 20 - structopt = "0.3" 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 - syncat-stylesheet = { version = "2.1.4", features = ["ansi_term"] } 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 + 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 - 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 - #[derive(StructOpt, Debug)] 25 - #[structopt(name = "paper")] 26 - #[structopt(rename_all = "kebab-case")] 27 - #[structopt(setting = structopt::clap::AppSettings::ColoredHelp)] 24 + #[derive(clap::Parser, Debug)] 25 + #[clap(name = "paper")] 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 - #[structopt(short, long, default_value = "6")] 29 + #[structopt(short = 'm', long, default_value = "6")] 31 30 pub margin: usize, 32 31 33 32 /// Horizontal margin (overrides --margin) 34 - #[structopt(short, long)] 33 + #[structopt(long)] 35 34 pub h_margin: Option<usize>, 36 35 37 36 /// Vertical margin (overrides --margin) 38 - #[structopt(short, long)] 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 - #[structopt(short, long, default_value = "92")] 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 - #[structopt(short, long)] 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 - #[structopt(short = "u", long)] 53 + #[structopt(short = 'U', long)] 55 54 pub hide_urls: bool, 56 55 57 56 /// Disable drawing images 58 - #[structopt(short = "i", long)] 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 - #[structopt(short = "l", long)] 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 - #[structopt(short = "r", long)] 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 - #[structopt(name = "FILE", parse(from_os_str))] 77 + #[structopt(name = "FILE")] 79 78 pub files: Vec<PathBuf>, 80 79 } 81 80 ··· 235 234 } 236 235 237 236 fn main() { 238 - let opts = Opts::from_args(); 237 + let opts = Opts::parse(); 239 238 240 239 if opts.files.is_empty() { 241 240 let mut string = String::new();