File tree 2 files changed +50
-1
lines changed
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 1
1
pub mod anchor;
2
2
pub mod bold;
3
- pub mod headings;
4
3
pub mod footnote;
4
+ pub mod headings;
5
5
pub mod italic;
6
+ pub mod quote;
Original file line number Diff line number Diff line change
1
+ use brack_sdk_rs:: { MetaData , Type , Value } ;
2
+ use extism_pdk:: { plugin_fn, FnResult , Json , WithReturnCode } ;
3
+
4
+ #[ plugin_fn]
5
+ pub fn metadata_inline_quote ( ) -> FnResult < Json < MetaData > > {
6
+ Ok ( Json ( MetaData {
7
+ command_name : ">" . to_string ( ) ,
8
+ call_name : "inline_quote" . to_string ( ) ,
9
+ argument_types : vec ! [ ( "text" . to_string( ) , Type :: TInline ) ] ,
10
+ return_type : Type :: TInline ,
11
+ } ) )
12
+ }
13
+
14
+ #[ plugin_fn]
15
+ pub fn inline_quote ( Json ( args) : Json < Vec < Value > > ) -> FnResult < String > {
16
+ if args. len ( ) != 2 {
17
+ return Err ( WithReturnCode :: new (
18
+ anyhow:: anyhow!(
19
+ "Usage:
20
+ 1. [std.> text]
21
+ 2. [std.> text, cite]"
22
+ ) ,
23
+ 1 ,
24
+ ) ) ;
25
+ }
26
+ let text = match & args[ 0 ] {
27
+ Value :: Text ( t) => t,
28
+ _ => {
29
+ return Err ( WithReturnCode :: new (
30
+ anyhow:: anyhow!( "text must be Value::Text" ) ,
31
+ 1 ,
32
+ ) )
33
+ }
34
+ } ;
35
+ let cite = match & args[ 1 ] {
36
+ Value :: TextOption ( t) => t,
37
+ _ => {
38
+ return Err ( WithReturnCode :: new (
39
+ anyhow:: anyhow!( "text must be Value::TextOption" ) ,
40
+ 1 ,
41
+ ) )
42
+ }
43
+ } ;
44
+ match cite {
45
+ Some ( cite) => Ok ( format ! ( "<q cite=\" {}\" >{}</q>" , cite, text) ) ,
46
+ None => Ok ( format ! ( "<q>{}</q>" , text) ) ,
47
+ }
48
+ }
You can’t perform that action at this time.
0 commit comments