From e2cc5fb4e6fe4f5109dbb1afef8ff48da31541f2 Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 11:59:09 +1200 Subject: [PATCH 1/8] Bump Pandoc API version to 1.22 --- src/definition.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/definition.rs b/src/definition.rs index 2a11fc1..c680c97 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::ser::SerializeStruct; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -const PANDOC_API_VERSION: &'static [i32] = &[1, 20]; +const PANDOC_API_VERSION: &'static [i32] = &[1, 22]; #[derive(Debug, Clone, PartialEq)] pub struct Pandoc(pub Meta, pub Vec); From ef0690a042daa922d4ea83a9cab3e7ffcd5cfc6c Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 12:00:07 +1200 Subject: [PATCH 2/8] Add Underline inline variant --- src/definition.rs | 1 + tests/pandoc_compatibility.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/definition.rs b/src/definition.rs index c680c97..472ed99 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -102,6 +102,7 @@ pub enum Block { pub enum Inline { Str(String), Emph(Vec), + Underline(Vec), Strong(Vec), Strikeout(Vec), Superscript(Vec), diff --git a/tests/pandoc_compatibility.rs b/tests/pandoc_compatibility.rs index d7d486b..79b3aba 100644 --- a/tests/pandoc_compatibility.rs +++ b/tests/pandoc_compatibility.rs @@ -224,6 +224,7 @@ fn inline() { r#" str *emph* +underline **strong** ~~strikeout~~ ^superscript^ From bd3d1a8b7a12f8f04eb3afe853eaf586e61af92c Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 12:48:15 +1200 Subject: [PATCH 3/8] Update tables to pandoc-types 1.22 --- src/definition.rs | 42 ++++++++++++++++++++++++++++++++++-------- tests/tables.txt | 25 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/definition.rs b/src/definition.rs index 472ed99..d112242 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -87,11 +87,12 @@ pub enum Block { Header(i32, Attr, Vec), HorizontalRule, Table( - Vec, - Vec, - Vec, - Vec, - Vec>, + Attr, + Caption, + Vec, + TableHead, + Vec, + TableFoot, ), Div(Attr, Vec), Null, @@ -131,6 +132,34 @@ pub enum Alignment { AlignDefault, } +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +#[serde(tag = "t", content = "c")] +pub enum ColWidth { + ColWidth(f64), + ColWidthDefault, +} + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct ColSpec(pub Alignment, pub ColWidth); + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct Row(pub Attr, Vec); + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct TableHead(pub Attr, pub Vec); + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct TableBody(pub Attr, pub i32, pub Vec, pub Vec); + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct TableFoot(pub Attr, pub Vec); + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct Caption(pub Option>, pub Vec); + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct Cell(pub Attr, pub Alignment, pub i32, pub i32, pub Vec); + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct ListAttributes(pub i32, pub ListNumberStyle, pub ListNumberDelim); @@ -167,9 +196,6 @@ impl Attr { } } -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -pub struct TableCell(pub Vec); - #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(tag = "t", content = "c")] pub enum QuoteType { diff --git a/tests/tables.txt b/tests/tables.txt index e0d6806..883d218 100644 --- a/tests/tables.txt +++ b/tests/tables.txt @@ -72,3 +72,28 @@ Multiline table without column headers: Second row 5.0 Here's another one. Note the blank line between rows. ---------- --------- ----------- --------------------------- + +Table with column widths: + + + + + + + + + + + + + + + + + + + + + + +
FirstSecond
AB
CD
From 04d2c08350c94fb948f644a7b61e84b89f2579b9 Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 12:53:27 +1200 Subject: [PATCH 4/8] Update version in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d3b7cd..5c9dcfd 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ itself. If that's what you're looking for, consider the ## Compatibility The current version is **compatible with Haskell pandoc-types -1.20**. This is the most recent version at the time of writing. +1.22**. This is the most recent version at the time of writing. ## Supported modules From 2e94add916a61534218ee0a90addf7aca82bd94a Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 13:11:38 +1200 Subject: [PATCH 5/8] Migrate to GitHub Workflows for CI --- .github/workflows/test.yml | 49 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 22 ----------------- README.md | 2 +- 3 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..482bd68 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + - name: Setup pandoc + uses: r-lib/actions/setup-pandoc@v1 + with: + pandoc-version: 2.14.0.3 + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Run cargo build + uses: actions-rs/cargo@v1 + with: + command: build + + - name: Run examples + uses: actions-rs/cargo@v1 + with: + command: run + args: --example definition diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9f287ca..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -sudo: true -distro: xenial -language: rust - -rust: - - stable - - beta - -cache: - cargo: true - -before_script: - - wget https://github.com/jgm/pandoc/releases/download/2.9.2.1/pandoc-2.9.2.1-1-amd64.deb - - sudo dpkg -i pandoc-2.9.2.1-1-amd64.deb - - rustup component add rustfmt - -script: - - cargo clean - - cargo fmt -- --check - - cargo build - - cargo test - - cargo run --example definition diff --git a/README.md b/README.md index 5c9dcfd..7fe13c9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Rust port of pandoc-types [![Build Status](https://travis-ci.org/elliottslaughter/rust-pandoc-types.svg?branch=master)](https://travis-ci.org/elliottslaughter/rust-pandoc-types) +# Rust port of pandoc-types ![Build status](https://github.com/nokome/rust-pandoc-types/actions/workflows/test.yml/badge.svg) This library provides a Rust port of the [pandoc-types Haskell package](https://hackage.haskell.org/package/pandoc-types). From 9c52646593ce6900e14f2f29eabc0847d1957e1a Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 13:17:06 +1200 Subject: [PATCH 6/8] Clippy linting fixes, remove badges from Cargo.toml --- .github/workflows/test.yml | 1 - Cargo.toml | 3 --- src/definition.rs | 6 +++--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 482bd68..6a37a4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,6 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: -- -D warnings - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v1 diff --git a/Cargo.toml b/Cargo.toml index 8c8119e..8399bb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,6 @@ readme = "README.md" include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "tests/**/*.txt", "examples/**/*.rs", "README.md", "LICENSE.txt"] edition = "2018" -[badges] -travis-ci = { repository = "elliottslaughter/rust-pandoc-types" } - [dependencies] serde = {version = "1.0", features=["derive"]} serde_json = "1.0" diff --git a/src/definition.rs b/src/definition.rs index d112242..968a564 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::ser::SerializeStruct; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -const PANDOC_API_VERSION: &'static [i32] = &[1, 22]; +const PANDOC_API_VERSION: [i32; 2] = [1, 22]; #[derive(Debug, Clone, PartialEq)] pub struct Pandoc(pub Meta, pub Vec); @@ -14,7 +14,7 @@ impl Serialize for Pandoc { S: Serializer, { let mut value = serializer.serialize_struct("Pandoc", 3)?; - value.serialize_field("pandoc-api-version", PANDOC_API_VERSION)?; + value.serialize_field("pandoc-api-version", &PANDOC_API_VERSION)?; value.serialize_field("meta", &self.0)?; value.serialize_field("blocks", &self.1)?; value.end() @@ -56,7 +56,7 @@ impl Meta { self.0.is_empty() } - pub fn lookup(&self, key: &String) -> Option<&MetaValue> { + pub fn lookup(&self, key: &str) -> Option<&MetaValue> { self.0.get(key) } } From fbebad98f05e40a519b2a11e58146809c24fa605 Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Tue, 6 Jul 2021 17:29:38 +1200 Subject: [PATCH 7/8] Make row cells public --- src/definition.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/definition.rs b/src/definition.rs index 968a564..06a8a4b 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -143,7 +143,7 @@ pub enum ColWidth { pub struct ColSpec(pub Alignment, pub ColWidth); #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -pub struct Row(pub Attr, Vec); +pub struct Row(pub Attr, pub Vec); #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct TableHead(pub Attr, pub Vec); From 64367d52b1d8fa42d4afcaa6f547d5906dc80d04 Mon Sep 17 00:00:00 2001 From: Nokome Bentley Date: Wed, 7 Jul 2021 16:47:52 +1200 Subject: [PATCH 8/8] Change URL of status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fe13c9..e47a9ef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Rust port of pandoc-types ![Build status](https://github.com/nokome/rust-pandoc-types/actions/workflows/test.yml/badge.svg) +# Rust port of pandoc-types ![Build status](https://github.com/elliottslaughter/rust-pandoc-types/actions/workflows/test.yml/badge.svg) This library provides a Rust port of the [pandoc-types Haskell package](https://hackage.haskell.org/package/pandoc-types).