summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-31 13:57:13 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-31 18:03:26 +0200
commitf6f9734cd8afbbcb43fa65fb4e554c06049c00e9 (patch)
tree02738189d0a8854216133aa18ae3ed4a2fcc2553
parenta3dd2121847584242475bbb6580c4120c547630c (diff)
mdcat: 0.15 -> 0.17, syntect: 3 -> 4
And update the implementation for the new mdcat interface. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--lib/entry/libimagentryview/Cargo.toml4
-rw-r--r--lib/entry/libimagentryview/src/builtin/md.rs39
2 files changed, 18 insertions, 25 deletions
diff --git a/lib/entry/libimagentryview/Cargo.toml b/lib/entry/libimagentryview/Cargo.toml
index 4e0a1f78..bd5044ce 100644
--- a/lib/entry/libimagentryview/Cargo.toml
+++ b/lib/entry/libimagentryview/Cargo.toml
@@ -30,7 +30,7 @@ libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore"
libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" }
libimagentryedit = { version = "0.10.0", path = "../../../lib/entry/libimagentryedit" }
-mdcat = { version = "0.15.0", optional = true }
+mdcat = { version = "0.17.0", optional = true }
[dependencies.pulldown-cmark]
version = "^0.7"
@@ -39,7 +39,7 @@ default-features = false
features = []
[dependencies.syntect]
-version = "3"
+version = "4"
optional = true
default-features = false
features = ["parsing", "assets", "dump-load"]
diff --git a/lib/entry/libimagentryview/src/builtin/md.rs b/lib/entry/libimagentryview/src/builtin/md.rs
index b4bd13c6..771be295 100644
--- a/lib/entry/libimagentryview/src/builtin/md.rs
+++ b/lib/entry/libimagentryview/src/builtin/md.rs
@@ -30,22 +30,11 @@ use anyhow::format_err;
use crate::viewer::Viewer;
-pub struct MarkdownViewer<'a> {
- rt: &'a Runtime<'a>,
- resource_access: ResourceAccess,
- termsize: TerminalSize,
-}
+pub struct MarkdownViewer<'a>(&'a Runtime<'a>);
impl<'a> MarkdownViewer<'a> {
pub fn new(rt: &'a Runtime) -> Self {
- MarkdownViewer {
- rt,
- resource_access: ResourceAccess::LocalOnly,
- termsize: TerminalSize::detect().unwrap_or(TerminalSize {
- width: 80,
- height: 20,
- }),
- }
+ MarkdownViewer(rt)
}
}
@@ -53,18 +42,22 @@ impl<'a> Viewer for MarkdownViewer<'a> {
fn view_entry<W>(&self, e: &Entry, sink: &mut W) -> Result<()>
where W: Write
{
- let parser = Parser::new(e.get_content());
- let base_dir = self.rt.rtp();
- let syntax_set = SyntaxSet::load_defaults_newlines();
- let capa = TerminalCapabilities::ansi();
+ let parser = Parser::new(e.get_content());
+ let base_dir = self.0.rtp();
+ let settings = mdcat::Settings {
+ terminal_capabilities: TerminalCapabilities::ansi(),
+ syntax_set: SyntaxSet::load_defaults_newlines(),
+ resource_access: ResourceAccess::LocalOnly,
+ terminal_size: TerminalSize::detect().unwrap_or(TerminalSize {
+ width: 80,
+ height: 20,
+ }),
+ };
- ::mdcat::push_tty(sink,
- &capa,
- self.termsize,
- parser,
+ ::mdcat::push_tty(&settings,
+ sink,
base_dir,
- self.resource_access,
- syntax_set)
+ parser)
.map_err(|_| format_err!("Failed while formatting markdown"))
}
}