Skip to content
Myr

asciidoc.rs

This file

Path

src/export/asciidoc.rs

76 lines · 1.9 KiB · Rust

Last changed by

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

History of this file

Take it

The walk stopped after 200 commits: lines older than 0f91d0c point at it.

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 1–26why, one step back
1use super::markup::Alignment;
2use crate::export::markup::MarkupExporter;34#[derive(Default)]5pub struct AsciidocExporter {}67impl MarkupExporter for AsciidocExporter {8 fn table_header(&self, cell_aligmnents: &[Alignment]) -> String {9 format!(10 "[cols=\"{}\"]\n|===",11 cell_aligmnents12 .iter()13 .map(|a| match a {14 Alignment::Left => "<",15 Alignment::Right => ">",16 })17 .collect::<Vec<&str>>()18 .join(",")19 )20 }2122 fn table_footer(&self, _cell_aligmnents: &[Alignment]) -> String {23 "|===\n".to_string()24 }2526 fn table_row(&self, cells: &[&str]) -> String {

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 27–36why, one step back
27 let mut row = String::from("\n");
28 for cell in cells {29 row.push('|');30 if !cell.is_empty() {31 row.push(' ');32 row.push_str(cell);33 }34 row.push('\n');35 }36 row

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 37–43why, one step back
37 }
3839 fn table_divider(&self, _cell_aligmnents: &[Alignment]) -> String {40 "".to_string()41 }4243 fn command(&self, cmd: &str) -> String {

style: simplify string interpolationHamir Mahalbefore adoptionef12632

line 44why, one step back
44 format!("`{cmd}`")

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 45–54why, one step back
45 }
46}4748/// Check Asciidoc-based data row formatting49#[test]50fn test_asciidoc_exporter_table_data() {51 let exporter = AsciidocExporter::default();52 let data = vec!["a", "b", "c"];5354 let actual = exporter.table_row(&data);

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 55why, one step back
55 let expect = "\n| a\n| b\n| c\n";

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 56–76why, one step back
56
57 assert_eq!(expect, actual);58}5960/// Check Asciidoc-based table header formatting61#[test]62fn test_asciidoc_exporter_table_header() {63 let exporter = AsciidocExporter::default();64 let cells_alignment = [65 Alignment::Left,66 Alignment::Right,67 Alignment::Right,68 Alignment::Right,69 Alignment::Right,70 ];7172 let actual = exporter.table_header(&cells_alignment);73 let expect = "[cols=\"<,>,>,>,>\"]\n|===";7475 assert_eq!(expect, actual);76}