Skip to content
Myr

orgmode.rs

This file

Path

src/export/orgmode.rs

51 lines · 1.2 KiB · Rust

Last changed by

Move more tests to instaDavid Peterbefore adoptionda399ab

History of this file

Take it

1use super::markup::Alignment;2use crate::export::markup::MarkupExporter;34#[derive(Default)]5pub struct OrgmodeExporter {}67impl MarkupExporter for OrgmodeExporter {8    fn table_row(&self, cells: &[&str]) -> String {9        format!(10            "| {}  |  {} |\n",11            cells.first().unwrap(),12            &cells[1..].join(" |  ")13        )14    }1516    fn table_divider(&self, cell_aligmnents: &[Alignment]) -> String {17        format!("|{}--|\n", "--+".repeat(cell_aligmnents.len() - 1))18    }1920    fn command(&self, cmd: &str) -> String {21        format!("={cmd}=")22    }23}2425/// Check Emacs org-mode data row formatting26#[test]27fn test_orgmode_formatter_table_data() {28    let exporter = OrgmodeExporter::default();2930    let actual = exporter.table_row(&["a", "b", "c"]);31    let expect = "| a  |  b |  c |\n";3233    assert_eq!(expect, actual);34}3536/// Check Emacs org-mode horizontal line formatting37#[test]38fn test_orgmode_formatter_table_line() {39    let exporter = OrgmodeExporter::default();4041    let actual = exporter.table_divider(&[42        Alignment::Left,43        Alignment::Left,44        Alignment::Left,45        Alignment::Left,46        Alignment::Left,47    ]);48    let expect = "|--+--+--+--+--|\n";4950    assert_eq!(expect, actual);51}