(code: String, options: Option<JsObject>)
| 4 | |
| 5 | #[napi(js_name = "renderFencedCode")] |
| 6 | pub fn render_fenced_code(code: String, options: Option<JsObject>) -> Option<Vec<String>> { |
| 7 | let width = options |
| 8 | .as_ref() |
| 9 | .and_then(|opts| opts.get_named_property::<u32>("terminalWidth").ok()) |
| 10 | .filter(|&w| w > 0) |
| 11 | .unwrap_or(80); |
| 12 | |
| 13 | Some(wrap_with_width(&code, width as usize)) |
| 14 | } |
| 15 | |
| 16 | fn wrap_with_width(code: &str, width: usize) -> Vec<String> { |
| 17 | let width = width.max(1); |
nothing calls this directly
no test coverage detected