pub fn words(markdown: &str) -> usizeExpand description
Examples found in repository?
examples/basic_usage.rs (line 32)
3fn main() {
4 let markdown_content = r#"
5# 我的第一篇博客文章
6
7这是一些示例内容,用来演示如何使用 markdown-readtime 库。
8
9## 子标题
10
11我们还可以添加一些列表:
12- 第一项
13- 第二项
14- 第三项
15
16以及一些代码示例:
17
18```rust
19fn main() {
20 println!("Hello, world!");
21}"#;
22 // 获取完整的阅读时间信息
23 let read_time = estimate(markdown_content);
24 println!("总阅读时间: {}秒", read_time.total_seconds);
25 println!("格式化时间: {}", read_time.formatted);
26 println!("字数统计: {}", read_time.word_count);
27 println!("图片数量: {}", read_time.image_count);
28 println!("代码块数量: {}", read_time.code_block_count);
29
30 // 或者使用快捷函数
31 println!("预计需要 {} 分钟读完", minutes(markdown_content));
32 println!("大约有 {} 个字", words(markdown_content));
33 println!("阅读时间: {}", formatted(markdown_content));
34}