From 7d10e59379952f6a1dbd03ceea10c6df515033c4 Mon Sep 17 00:00:00 2001 From: KmolYuan Date: Thu, 12 May 2022 11:11:28 +0800 Subject: [PATCH] Update docs. --- README.md | 25 ++++++++++--------------- src/project/content/marked.rs | 19 ++++++++----------- src/project/mod.rs | 20 ++++++++++++-------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 5b3d7a3..79eb2c8 100644 --- a/README.md +++ b/README.md @@ -58,26 +58,21 @@ The executable can be checked with `rym` command. The command `rym` stands for "Reveal-Yaml Manager". -```bash -# Download the latest Reveal.js archive -rym update -# Create/Initialize a project to current directory -# Only "reveal.yaml" will be create, the rest is up to you! -rym new PROJECT_PATH -rym init -# Serve the slides -rym serve -# Reformat the project file -rym fmt -# Pack the project to HTML archive -rym pack -``` +| Command | Description | +|:--------|:------------------------------------------------| +| help | Show the CLI help message | +| update | Download the Reveal.js resources | +| new | Create a new project and its directory | +| init | Create a new project from an existing directory | +| serve | Serve the current project | +| fmt | Format the current project | +| pack | Pack the current project | Please see `rym --help`/`rym subcommand --help` for more information. ### Edit Mode (Hot Reload / Auto-reload) -There are `-e` / `--edit` flags on the `serve` command. This option let the server keep watching the project file `reveal.yaml`, then reload the page from the web browser. (via JS & WebSocket) +There are `-e`/`--edit` flags on the `serve` command. This option let the server keep watching the project file `reveal.yaml`, then reload the page from the web browser. (via JS & WebSocket) If this option is not enabled, the server will only resolve once at startup, and always use the cache. diff --git a/src/project/content/marked.rs b/src/project/content/marked.rs index 2f9b8d9..d81b1fc 100644 --- a/src/project/content/marked.rs +++ b/src/project/content/marked.rs @@ -1,11 +1,12 @@ use pulldown_cmark::{html::push_html, CodeBlockKind, Event, Options, Parser, Tag}; -const MARKED: Options = Options::from_bits_truncate( - Options::ENABLE_TABLES.bits() +const MARKED: Options = { + let bits = Options::ENABLE_TABLES.bits() | Options::ENABLE_SMART_PUNCTUATION.bits() | Options::ENABLE_TASKLISTS.bits() - | Options::ENABLE_STRIKETHROUGH.bits(), -); + | Options::ENABLE_STRIKETHROUGH.bits(); + Options::from_bits_truncate(bits) +}; fn marked(e: Event) -> Event { match e { @@ -34,11 +35,7 @@ fn marked(e: Event) -> Event { /// Translate Markdown to HTML. pub fn md2html(text: &str) -> String { - if text.is_empty() { - "".to_string() - } else { - let mut out = String::new(); - push_html(&mut out, Parser::new_ext(text, MARKED).map(marked)); - out - } + let mut doc = String::new(); + push_html(&mut doc, Parser::new_ext(text, MARKED).map(marked)); + doc } diff --git a/src/project/mod.rs b/src/project/mod.rs index 8a6f30d..3e2f89b 100644 --- a/src/project/mod.rs +++ b/src/project/mod.rs @@ -44,28 +44,32 @@ //! //! ### Multi-document Mode //! -//! A regular Reveal.yaml project can be: +//! A regular Reveal.yaml project has two parts, metadata and a list of slides. +//! [`Metadata`] and [`Slides`]. //! //! ```yaml -//! ## metadata block (map) +//! ## metadata block (map) - Metadata //! --- -//! ## Slider block (sequence) +//! ## Slider block (sequence) - Sliders //! - title: Title 1 //! - title: Title 2 //! ``` //! //! Or multi-document with a leading metadata doc to reduce the indents. +//! [`Metadata`] and [`ChapterSlide`]. //! //! ```yaml -//! ## metadata block (map) +//! ## metadata block (map) - Metadata //! --- -//! ## Slider block 1 (map) +//! ## Slider block 1 (map) - ChapterSlide //! title: Title 1 //! --- -//! ## Slider block 2 (map) +//! ## Slider block 2 (map) - ChapterSlide //! title: Title 2 //! ``` //! +//! Please be aware that anchors cannot be referenced between different documents. +//! //! ### Layout //! //! There are two layout types, called "horizontal stack" ([`Content::h_stack`]) and "vertical stack" ([`Content::v_stack`]). The vertical layout is default, as same as HTML. @@ -85,8 +89,8 @@ //! //! ```yaml //! h-stack-border: -//! - doc: Splitted left -//! - doc: Splitted right +//! - doc: Left +//! - doc: Right //! ``` //! //! ### Sized Attribute