Skip to content

Commit

Permalink
bump edition again (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: flying-sheep <[email protected]>
  • Loading branch information
flying-sheep and flying-sheep authored Feb 20, 2025
1 parent c399fea commit 3ed3547
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 41 deletions.
2 changes: 1 addition & 1 deletion document_tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = 'document_tree'
version = "0.4.1"
authors = ['Philipp A. <[email protected]>']
edition = '2021'
edition = '2024'
description = 'reStructuredText’s DocumentTree representation'
license = 'MIT OR Apache-2.0'
readme = 'README.md'
Expand Down
2 changes: 1 addition & 1 deletion document_tree/src/attribute_types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

use anyhow::{bail, format_err, Error};
use anyhow::{Error, bail, format_err};
use regex::Regex;
use serde_derive::Serialize;

Expand Down
2 changes: 1 addition & 1 deletion document_tree/src/elements.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde_derive::Serialize;
use std::path::PathBuf;

use crate::attribute_types::{CanBeEmpty, NameToken, ID};
use crate::attribute_types::{CanBeEmpty, ID, NameToken};
use crate::element_categories::*;
use crate::extra_attributes::{self, ExtraAttributes};

Expand Down
4 changes: 2 additions & 2 deletions document_tree/src/extra_attributes.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde_derive::Serialize;

use crate::attribute_types::{
AlignH, AlignHV, AlignV, CanBeEmpty, EnumeratedListType, FixedSpace, Measure, NameToken,
TableAlignH, TableBorder, TableGroupCols, ID,
AlignH, AlignHV, AlignV, CanBeEmpty, EnumeratedListType, FixedSpace, ID, Measure, NameToken,
TableAlignH, TableBorder, TableGroupCols,
};
use crate::url::Url;

Expand Down
16 changes: 9 additions & 7 deletions document_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ mod tests {

#[test]
fn descriptive() {
let doc = Document::with_children(vec![Title::with_children(vec![
"Hi".into(),
ImageInline::with_extra(extra_attributes::ImageInline::new(
"https://example.com/image.jpg".parse().unwrap(),
))
let doc = Document::with_children(vec![
Title::with_children(vec![
"Hi".into(),
ImageInline::with_extra(extra_attributes::ImageInline::new(
"https://example.com/image.jpg".parse().unwrap(),
))
.into(),
])
.into(),
])
.into()]);
]);

println!("{:?}", doc);
}
Expand Down
2 changes: 1 addition & 1 deletion parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = 'rst_parser'
version = "0.4.1"
authors = ['Philipp A. <[email protected]>']
edition = '2021'
edition = '2024'
description = 'a reStructuredText parser'
license = 'MIT OR Apache-2.0'
readme = 'README.md'
Expand Down
4 changes: 2 additions & 2 deletions parser/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use anyhow::Error;
use pest::iterators::Pairs;

use document_tree::{
attribute_types as at, element_categories as c, elements as e, Element, HasChildren,
Element, HasChildren, attribute_types as at, element_categories as c, elements as e,
};

use crate::pest_rst::Rule;

fn ssubel_to_section_unchecked_mut(ssubel: &mut c::StructuralSubElement) -> &mut e::Section {
match ssubel {
c::StructuralSubElement::SubStructure(ref mut b) => match **b {
c::StructuralSubElement::SubStructure(b) => match **b {
c::SubStructure::Section(ref mut s) => s,
_ => unreachable!(),
},
Expand Down
6 changes: 3 additions & 3 deletions parser/src/conversion/block.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::{bail, Error};
use anyhow::{Error, bail};
use pest::iterators::Pair;

use document_tree::{
attribute_types as at, element_categories as c, elements as e, extra_attributes as a, Element,
ExtraAttributes, HasChildren,
Element, ExtraAttributes, HasChildren, attribute_types as at, element_categories as c,
elements as e, extra_attributes as a,
};

use super::{inline::convert_inlines, whitespace_normalize_name};
Expand Down
4 changes: 2 additions & 2 deletions parser/src/conversion/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use anyhow::Error;
use pest::iterators::Pair;

use document_tree::{
attribute_types as at, element_categories as c, elements as e, extra_attributes as a, url::Url,
HasChildren,
HasChildren, attribute_types as at, element_categories as c, elements as e,
extra_attributes as a, url::Url,
};

use super::whitespace_normalize_name;
Expand Down
14 changes: 7 additions & 7 deletions parser/src/conversion/tests.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
use document_tree::{
element_categories as c, elements as e, extra_attributes::ExtraAttributes, HasChildren,
HasChildren, element_categories as c, elements as e, extra_attributes::ExtraAttributes,
};

use crate::parse;

fn ssubel_to_section(ssubel: &c::StructuralSubElement) -> &e::Section {
match ssubel {
c::StructuralSubElement::SubStructure(ref b) => match **b {
c::StructuralSubElement::SubStructure(b) => match **b {
c::SubStructure::Section(ref s) => s,
ref c => panic!("Expected section, not {:?}", c),
},
ref c => panic!("Expected SubStructure, not {:?}", c),
c => panic!("Expected SubStructure, not {:?}", c),
}
}

fn ssubel_to_body_element(ssubel: &c::StructuralSubElement) -> &c::BodyElement {
match ssubel {
c::StructuralSubElement::SubStructure(ref b) => match **b {
c::StructuralSubElement::SubStructure(b) => match **b {
c::SubStructure::BodyElement(ref b) => b,
ref c => panic!("Expected BodyElement, not {:?}", c),
},
ref c => panic!("Expected SubStructure, not {:?}", c),
c => panic!("Expected SubStructure, not {:?}", c),
}
}

fn body_element_to_image(bodyel: &c::BodyElement) -> &e::Image {
match bodyel {
c::BodyElement::Image(ref i) => i,
ref c => panic!("Expected Image, not {:?}", c),
c::BodyElement::Image(i) => i,
c => panic!("Expected Image, not {:?}", c),
}
}

Expand Down
2 changes: 1 addition & 1 deletion parser/src/pair_ext_parse.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::str::FromStr;

use pest::Span;
use pest::error::{Error, ErrorVariant};
use pest::iterators::Pair;
use pest::Span;

pub trait PairExt<R>
where
Expand Down
2 changes: 1 addition & 1 deletion parser/src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ TODO: continue documenting how it’s done via https://repo.or.cz/docutils.git/b
use std::collections::HashMap;

use document_tree::{
Document, HasChildren,
attribute_types::NameToken,
element_categories as c,
elements::{self as e, Element},
extra_attributes::ExtraAttributes,
url::Url,
Document, HasChildren,
};

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = 'rst_renderer'
version = "0.4.1"
authors = ['Philipp A. <[email protected]>']
edition = '2021'
edition = '2024'
description = 'a reStructuredText renderer'
license = 'MIT OR Apache-2.0'
readme = 'README.md'
Expand Down
12 changes: 6 additions & 6 deletions renderer/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use anyhow::Error;

// use crate::url::Url;
use document_tree::{
attribute_types as at, element_categories as c, elements as e, extra_attributes as a, Document,
Element, ExtraAttributes, HasChildren,
Document, Element, ExtraAttributes, HasChildren, attribute_types as at,
element_categories as c, elements as e, extra_attributes as a,
};

// static FOOTNOTE_SYMBOLS: [char; 10] = ['*', '†', '‡', '§', '¶', '#', '♠', '♥', '♦', '♣'];
Expand Down Expand Up @@ -265,15 +265,15 @@ where
W: Write,
{
let extra = self.extra();
if let Some(ref target) = extra.target {
if let Some(target) = extra.target.as_ref() {
write!(
renderer.stream,
"<a href=\"{}\">",
escape_html(target.as_str())
)?;
}
write!(renderer.stream, "<img")?;
if let Some(ref alt) = extra.alt {
if let Some(alt) = extra.alt.as_ref() {
write!(renderer.stream, " alt=\"{}\"", escape_html(alt))?;
}
// TODO: align: Option<AlignHV>
Expand Down Expand Up @@ -461,15 +461,15 @@ impl HTMLRender for e::Reference {
{
let extra = self.extra();
write!(renderer.stream, "<a")?;
if let Some(ref target) = extra.refuri {
if let Some(target) = extra.refuri.as_ref() {
write!(
renderer.stream,
" href=\"{}\"",
escape_html(target.as_str())
)?;
}
/*
if let Some(ref name) = extra.name {
if let Some(name) = extra.name.as_ref() {
write!(renderer.stream, " title=\"{}\"", escape_html(&name.0))?;
}
*/
Expand Down
9 changes: 6 additions & 3 deletions renderer/src/html/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ reference and the target.</p>\

#[test]
fn standalone_hyperlinks() {
check_renders_to("\
check_renders_to(
"\
Some http://url and a not_url_scheme:foo that is not supposed to be an url.
", "\
",
"\
<p>Some <a href=\"http://url/\">http://url</a> and a not_url_scheme:foo that is not supposed to be an url.</p>\
");
",
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod html;

use std::io::Write;

use anyhow::{anyhow, Error};
use anyhow::{Error, anyhow};

use document_tree::Document;

Expand Down
2 changes: 1 addition & 1 deletion rst/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = 'rst'
version = "0.4.1"
authors = ['Philipp A. <[email protected]>']
edition = '2021'
edition = '2024'
description = 'a reStructuredText parser and renderer for the command line'
license = 'MIT OR Apache-2.0'
readme = 'README.md'
Expand Down

0 comments on commit 3ed3547

Please sign in to comment.