@@ -6,11 +6,27 @@ pub fn metadata_inline_quote() -> FnResult<Json<MetaData>> {
6
6
Ok ( Json ( MetaData {
7
7
command_name : ">" . to_string ( ) ,
8
8
call_name : "inline_quote" . to_string ( ) ,
9
- argument_types : vec ! [ ( "text" . to_string( ) , Type :: TInline ) ] ,
9
+ argument_types : vec ! [
10
+ ( "text" . to_string( ) , Type :: TInline ) ,
11
+ ( "cite" . to_string( ) , Type :: TOption ( Box :: new( Type :: TInline ) ) ) ,
12
+ ] ,
10
13
return_type : Type :: TInline ,
11
14
} ) )
12
15
}
13
16
17
+ #[ plugin_fn]
18
+ pub fn metadata_block_quote ( ) -> FnResult < Json < MetaData > > {
19
+ Ok ( Json ( MetaData {
20
+ command_name : ">" . to_string ( ) ,
21
+ call_name : "block_quote" . to_string ( ) ,
22
+ argument_types : vec ! [
23
+ ( "text" . to_string( ) , Type :: TInline ) ,
24
+ ( "cite" . to_string( ) , Type :: TOption ( Box :: new( Type :: TInline ) ) ) ,
25
+ ] ,
26
+ return_type : Type :: TBlock ,
27
+ } ) )
28
+ }
29
+
14
30
#[ plugin_fn]
15
31
pub fn inline_quote ( Json ( args) : Json < Vec < Value > > ) -> FnResult < String > {
16
32
if args. len ( ) != 2 {
@@ -46,3 +62,42 @@ pub fn inline_quote(Json(args): Json<Vec<Value>>) -> FnResult<String> {
46
62
None => Ok ( format ! ( "<q>{}</q>" , text) ) ,
47
63
}
48
64
}
65
+
66
+ #[ plugin_fn]
67
+ pub fn block_quote ( Json ( args) : Json < Vec < Value > > ) -> FnResult < String > {
68
+ if args. len ( ) != 2 {
69
+ return Err ( WithReturnCode :: new (
70
+ anyhow:: anyhow!(
71
+ "Usage:
72
+ 1. {{std.> text}}
73
+ 2. {{std.> text, cite}}"
74
+ ) ,
75
+ 1 ,
76
+ ) ) ;
77
+ } ;
78
+ let text = match & args[ 0 ] {
79
+ Value :: Text ( t) => t,
80
+ _ => {
81
+ return Err ( WithReturnCode :: new (
82
+ anyhow:: anyhow!( "text must be Value::Text" ) ,
83
+ 1 ,
84
+ ) )
85
+ }
86
+ } ;
87
+ let cite = match & args[ 1 ] {
88
+ Value :: TextOption ( t) => t,
89
+ _ => {
90
+ return Err ( WithReturnCode :: new (
91
+ anyhow:: anyhow!( "text must be Value::TextOption" ) ,
92
+ 1 ,
93
+ ) )
94
+ }
95
+ } ;
96
+ match cite {
97
+ Some ( cite) => Ok ( format ! (
98
+ "<blockquote cite=\" {}\" >{}</blockquote>" ,
99
+ cite, text
100
+ ) ) ,
101
+ None => Ok ( format ! ( "<blockquote>{}</blockquote>" , text) ) ,
102
+ }
103
+ }
0 commit comments