1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use super::prelude::*;
pub const BLOCK_BOLD: BlockRule = BlockRule {
name: "block-bold",
accepts_names: &["b", "bold", "strong"],
accepts_star: false,
accepts_score: false,
accepts_newlines: false,
parse_fn,
};
fn parse_fn<'r, 't>(
parser: &mut Parser<'r, 't>,
name: &'t str,
flag_star: bool,
flag_score: bool,
in_head: bool,
) -> ParseResult<'r, 't, Elements<'t>> {
info!("Parsing bold block (name '{name}', in-head {in_head})");
assert!(!flag_star, "Bold doesn't allow star flag");
assert!(!flag_score, "Bold doesn't allow score flag");
assert_block_name(&BLOCK_BOLD, name);
let arguments = parser.get_head_map(&BLOCK_BOLD, in_head)?;
let (elements, errors, paragraph_safe) =
parser.get_body_elements(&BLOCK_BOLD, false)?.into();
let element = Element::Container(Container::new(
ContainerType::Bold,
elements,
arguments.to_attribute_map(parser.settings()),
));
ok!(paragraph_safe; element, errors)
}