Commit d6c7becfde

d6c7becfdedcaae0c782a0dce8290b3047e01c0a

parent: 5d668724e1

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2021-02-07 16:19 UTC

config: Add a config option to disable markdown input parsing

Layout: unified · split

src/config.rs +11
@@ -84,6 +84,7 @@ impl From<i32> for ServerBuffer {
84 84
85config!( 85config!(
86 "matrix-rust", 86 "matrix-rust",
87
87 Section look { 88 Section look {
88 encrypted_room_sign: String { 89 encrypted_room_sign: String {
89 // Description. 90 // Description.
@@ -121,6 +122,7 @@ config!(
121 RedactionStyle, 122 RedactionStyle,
122 }, 123 },
123 }, 124 },
125
124 Section network { 126 Section network {
125 debug_buffer: bool { 127 debug_buffer: bool {
126 // Description 128 // Description
@@ -128,6 +130,15 @@ config!(
128 // Default value. 130 // Default value.
129 false, 131 false,
130 }, 132 },
133 },
134
135 Section input {
136 markdown_input: bool {
137 // Description
138 "Should the input be parsed as markdown",
139 // Default value.
140 true,
141 },
131 } 142 }
132); 143);
133 144
src/room/mod.rs +6 −3
@@ -337,9 +337,12 @@ impl RoomHandle {
337#[async_trait(?Send)] 337#[async_trait(?Send)]
338impl BufferInputCallbackAsync for MatrixRoom { 338impl BufferInputCallbackAsync for MatrixRoom {
339 async fn callback(&mut self, _: BufferHandle, input: String) { 339 async fn callback(&mut self, _: BufferHandle, input: String) {
340 // TODO parse the input here and produce a formatted body. 340 let content = if self.config.borrow().input().markdown_input() {
341 let content = 341 MessageEventContent::Text(TextMessageEventContent::markdown(input))
342 MessageEventContent::Text(TextMessageEventContent::markdown(input)); 342 } else {
343 MessageEventContent::Text(TextMessageEventContent::plain(input))
344 };
345
343 self.send_message(content).await; 346 self.send_message(content).await;
344 } 347 }
345} 348}