markdown_that/plugins/cmark/inline/
emphasis.rs1use crate::generics::inline::emph_pair;
7use crate::{MarkdownThat, Node, NodeValue, Renderer};
8
9#[derive(Debug)]
10pub struct Em {
11 pub marker: char,
12}
13
14impl NodeValue for Em {
15 fn render(&self, node: &Node, fmt: &mut dyn Renderer) {
16 fmt.open("em", &node.attrs);
17 fmt.contents(&node.children);
18 fmt.close("em");
19 }
20}
21
22#[derive(Debug)]
23pub struct Strong {
24 pub marker: char,
25}
26
27impl NodeValue for Strong {
28 fn render(&self, node: &Node, fmt: &mut dyn Renderer) {
29 fmt.open("strong", &node.attrs);
30 fmt.contents(&node.children);
31 fmt.close("strong");
32 }
33}
34
35pub fn add(md: &mut MarkdownThat) {
36 emph_pair::add_with::<'*', 1, true>(md, || Node::new(Em { marker: '*' }));
37 emph_pair::add_with::<'_', 1, false>(md, || Node::new(Em { marker: '_' }));
38 emph_pair::add_with::<'*', 2, true>(md, || Node::new(Strong { marker: '*' }));
39 emph_pair::add_with::<'_', 2, false>(md, || Node::new(Strong { marker: '_' }));
40}