Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Split off pulldown-cmark-mdcat
Browse files Browse the repository at this point in the history
  • Loading branch information
swsnr committed Apr 12, 2023
1 parent e01485e commit 978d6b6
Show file tree
Hide file tree
Showing 2,634 changed files with 773 additions and 634 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt -- --check
- run: cargo fmt --all -- --check

manpage:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,8 +95,8 @@ jobs:
targets: ${{ matrix.target }}
components: clippy
# Build, including tests, to report build failures and measure build time separately from tests
- run: cargo build --all-targets --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo clippy --all-targets --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo test --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo doc --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo build --workspace --all-targets --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo clippy --workspace --all-targets --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo test --workspace --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo doc --workspace --locked --target ${{ matrix.target }} ${{ matrix.cargo_opts }}
- run: cargo run --target ${{ matrix.target }} ${{ matrix.cargo_opts }} -- sample/common-mark.md
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Use `cargo release` to create a new release.
- Update all dependencies.
- `mdcat::Settings` now holds a reference to a syntax set, so the syntax set can now be shared among multiple different settings.
- Explicitly set minimum rust version in `Cargo.toml`, and document MSRV policy.
- Move all core rendering functions into a new crate `pulldown-cmark-mdcat`; `mdcat` itself only contains the argument parsing and handling now.
If you were using `mdcat` as a library before, you likely want to use `pulldown-cmark-mdcat` now.

### Removed
- `mdcat::Settings.resource_access` and the corresponding `ResourceAccess` enum (see [GH-247]).
Expand Down
47 changes: 30 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 27 additions & 38 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,58 @@
name = "mdcat"
description = "cat for markdown: Show markdown documents in terminals"
readme = "README.md"
homepage = "https://github.com/swsnr/mdcat"
repository = "https://github.com/swsnr/mdcat"
documentation = "https://docs.rs/mdcat"
keywords = ["markdown", "less", "cat"]
version = "1.1.1"
categories = ["command-line-utilities", "text-processing"]
license = "MPL-2.0"
authors = ["Sebastian Wiesner <[email protected]>"]
edition = "2021"
rust-version = "1.67"
homepage.workspace = true
repository.workspace = true
version.workspace = true
categories.workspace = true
license.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true

[features]
default = ["native-tls"]
native-tls = ["reqwest/native-tls"]
# For static builds use rustls to avoid cross-building openssl, but use the
# native certificate roots for maximum compatibility
static = ["reqwest/rustls-tls-native-roots"]
default = ["pulldown-cmark-mdcat/native-tls"]
static = ["pulldown-cmark-mdcat/static"]

[dependencies]
anstyle = { version = "0.3.5", default-features = false }
anyhow = { version = "1.0.70", default-features = false, features = ["std"] }
base64 = { version = "0.21.0", default-features = false }
clap = { version = "4.2.1", default-features = false, features = ["std", "derive", "help", "usage", "error-context"] }
concolor-query = { version = "0.3.3", default-features = false }
gethostname = "0.4.1"
image = "0.24.6"
mime = { version = "0.3.17", default-features = false }
mime_guess = { version = "2.0.4", default-features = false }
once_cell = { version = "1.17.1", default-features = false }
pulldown-cmark = { version = "0.9.2", default-features = false, features = ['simd'] }
reqwest = { version = "0.11.16", default-features = false, features = ["gzip", "brotli", "blocking"]}
resvg = { version = "0.31.0", default-features = false, features = ["text", "system-fonts", "memmap-fonts"] }
shell-words = { version = "1.1.0", default-features = false, features = ["std"] }
syntect = { version = "5.0.0", default-features = false, features = ["parsing", "regex-fancy", "default-syntaxes"] }
system_proxy = { version = "0.3.2", default-features = false }
textwrap = { version = "0.16.0", default-features = false, features = ["unicode-linebreak", "unicode-width"] }
pulldown-cmark = { version = "0.9.2", default-features = false, features = ['simd'] }
pulldown-cmark-mdcat = { version = "1.1.1", path = "pulldown-cmark-mdcat", default-features = false }
syntect = { version = "5.0.0", default-features = false, features = ["regex-fancy", "default-syntaxes"] }
tracing = { version = "0.1.37", default-features = false, features = ["attributes"] }
tracing-subscriber = { version = "0.3.16", default-features = false, features = ["env-filter", "std", "fmt", "ansi"] }
url = "2.3.1"

[target.'cfg(unix)'.dependencies]
libc = "0.2.141"

[target.'cfg(windows)'.dependencies]
terminal_size = "0.2.6"

[dev-dependencies]
glob = "0.3.1"
hyper = { version="0.14.25", default-features = false, features = ["server", "http1", "runtime"] }
pretty_assertions = "1.3.0"
tokio = { version = "1.27", default-features = false, features = ["time"] }

[build-dependencies]
# To generate completions during build
clap = { version = "4.2.1", features = ["derive"] }
clap_complete = "4.2.0"
syntect = { version = "5.0.0", default-features = false, features = ["plist-load", "dump-create"] }

[profile.release]
# Enable LTO for release builds; makes the binary a lot smaller
lto = true

[package.metadata.release]
[workspace]
members = ["pulldown-cmark-mdcat"]

[workspace.package]
homepage = "https://github.com/swsnr/mdcat"
repository = "https://github.com/swsnr/mdcat"
version = "1.1.1"
categories = ["command-line-utilities", "text-processing"]
license = "MPL-2.0 AND Apache-2.0"
authors = ["Sebastian Wiesner <[email protected]>"]
edition = "2021"
rust-version = "1.67"

[workspace.metadata.release]
allow-branch = ["main"]
pre-release-commit-message = "Release {{version}}"
tag-prefix = "mdcat-"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Then it
Not supported:

* CommonMark extensions: [Footnotes][#1] and [tables][#2]
* [Re-filling paragraphs][#4]

[syntect]: https://github.com/trishume/syntect
[osc8]: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
Expand Down
13 changes: 2 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ use std::io::{Error, ErrorKind, Result};
use std::path::Path;
use std::process::Command;

use syntect::highlighting::ThemeSet;

#[allow(dead_code)]
mod mdcat {
include!("src/bin/mdcat/args.rs");
include!("src/args.rs");
}

fn gen_completions<P: AsRef<Path>>(out_dir: P) -> Result<()> {
Expand All @@ -31,13 +30,6 @@ fn gen_completions<P: AsRef<Path>>(out_dir: P) -> Result<()> {
Ok(())
}

fn generate_theme_dump<P: AsRef<Path>>(out_dir: P) {
let source_file = "src/render/Solarized (dark).tmTheme";
println!("cargo:rerun-if-changed={source_file}");
let theme = ThemeSet::get_theme(source_file).unwrap();
syntect::dumps::dump_to_file(&theme, out_dir.as_ref().join("theme.dump")).unwrap();
}

fn build_manpage<P: AsRef<Path>>(out_dir: P) -> Result<()> {
let target_file = out_dir.as_ref().join("mdcat.1");

Expand Down Expand Up @@ -68,7 +60,6 @@ fn build_manpage<P: AsRef<Path>>(out_dir: P) -> Result<()> {

fn main() {
let out_dir = std::env::var_os("OUT_DIR").expect("OUT_DIR not set");
generate_theme_dump(&out_dir);

println!("cargo:rerun-if-changed=src/bin/mdcat/args.rs");
if let Err(error) = gen_completions(&out_dir) {
Expand Down
57 changes: 57 additions & 0 deletions pulldown-cmark-mdcat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[package]
name = "pulldown-cmark-mdcat"
description = "Render pulldown-cmark events to TTY"
readme = "README.md"
documentation = "https://docs.rs/pulldown-cmark"
keywords = ["markdown", "less", "cat", "cmark"]
homepage.workspace = true
repository.workspace = true
version.workspace = true
categories.workspace = true
license.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true

[features]
default = ["native-tls"]
native-tls = ["reqwest/native-tls"]
# For static builds use rustls to avoid cross-building openssl, but use the
# native certificate roots for maximum compatibility
static = ["reqwest/rustls-tls-native-roots"]

[dependencies]
anyhow = { version = "1.0.70", default-features = false, features = ["std"] }
base64 = { version = "0.21.0", default-features = false }
anstyle = { version = "0.3.5", default-features = false }
gethostname = "0.4.1"
image = "0.24.6"
mime = { version = "0.3.17", default-features = false }
mime_guess = { version = "2.0.4", default-features = false }
once_cell = { version = "1.17.1", default-features = false }
pulldown-cmark = { version = "0.9.2", default-features = false, features = ['simd'] }
reqwest = { version = "0.11.16", default-features = false, features = ["gzip", "brotli", "blocking"]}
resvg = { version = "0.31.0", default-features = false, features = ["text", "system-fonts", "memmap-fonts"] }
syntect = { version = "5.0.0", default-features = false, features = ["parsing"] }
system_proxy = { version = "0.3.2", default-features = false }
textwrap = { version = "0.16.0", default-features = false, features = ["unicode-linebreak", "unicode-width"] }
tracing = { version = "0.1.37", default-features = false, features = ["attributes"] }
tracing-subscriber = { version = "0.3.16", default-features = false, features = ["env-filter", "std", "fmt", "ansi"] }
url = "2.3.1"

[dev-dependencies]
glob = "0.3.1"
hyper = { version="0.14.25", default-features = false, features = ["server", "http1", "runtime"] }
pretty_assertions = "1.3.0"
syntect = { version = "5.0.0", default-features = false, features = ["regex-fancy", "default-syntaxes"] }
tokio = { version = "1.27", default-features = false, features = ["time"] }

[build-dependencies]
syntect = { version = "5.0.0", default-features = false, features = ["plist-load", "dump-create"] }

[target.'cfg(unix)'.dependencies]
libc = "0.2.141"

[target.'cfg(windows)'.dependencies]
terminal_size = "0.2.6"

29 changes: 29 additions & 0 deletions pulldown-cmark-mdcat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# pulldown-cmark-mdcat

Render [pulldown-cmark] events to a TTY.

This library backs the [mdcat] tool, and makes its rendering available to other crates.

It supports:

- All common mark syntax.
- Standard ANSI formatting with OCS-8 hyperlinks.
- Inline images on terminal emulators with either the iTerm2 or the Kitty protocol, as well as on Terminology.
- Jump marks in iTerm2.

It does not support commonmark table and footnote extension syntax.

[mdcat]: https://github.com/swsnr/mdcat
[pulldown-cmark]: https://github.com/raphlinus/pulldown-cmark

## License

Copyright Sebastian Wiesner <[email protected]>

Binaries are subject to the terms of the Mozilla Public
License, v. 2.0, see [LICENSE](LICENSE).

Most of the source is subject to the terms of the Mozilla Public
License, v. 2.0, see [LICENSE](LICENSE), unless otherwise noted;
some files are subject to the terms of the Apache 2.0 license,
see <http://www.apache.org/licenses/LICENSE-2.0>
21 changes: 21 additions & 0 deletions pulldown-cmark-mdcat/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2020 Sebastian Wiesner <[email protected]>

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::path::Path;

use syntect::highlighting::ThemeSet;

fn generate_theme_dump<P: AsRef<Path>>(out_dir: P) {
let source_file = "src/render/Solarized (dark).tmTheme";
println!("cargo:rerun-if-changed={source_file}");
let theme = ThemeSet::get_theme(source_file).unwrap();
syntect::dumps::dump_to_file(&theme, out_dir.as_ref().join("theme.dump")).unwrap();
}

fn main() {
let out_dir = std::env::var_os("OUT_DIR").expect("OUT_DIR not set");
generate_theme_dump(&out_dir);
}
Loading

0 comments on commit 978d6b6

Please sign in to comment.