Skip to content

Commit 1ba57d5

Browse files
committed
chore: cargo fmt
1 parent 38d9a9e commit 1ba57d5

File tree

15 files changed

+86
-84
lines changed

15 files changed

+86
-84
lines changed

acdc-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use acdc_parser::{AttributeValue, DocumentAttributes};
66
use anyhow::Result;
77
use clap::{ArgAction, Parser, ValueEnum};
88
use tracing_subscriber::prelude::*;
9-
use tracing_subscriber::{fmt, EnvFilter};
9+
use tracing_subscriber::{EnvFilter, fmt};
1010

1111
#[derive(Debug, ValueEnum, Clone)]
1212
enum Backend {

acdc-parser/src/grammar/author_revision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ pub(crate) fn process_revision_info(
5353
document_attributes.insert("revremark".to_string(), AttributeValue::String(remark));
5454
}
5555
}
56-
}
56+
}

acdc-parser/src/grammar/document.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
#![allow(clippy::too_many_arguments)]
22
use crate::{
3-
error::Detail,
4-
grammar::{
5-
author_revision::{generate_initials, process_revision_info, RevisionInfo},
6-
inline_processing::{parse_inlines, preprocess_inline_content, process_inlines},
7-
location_mapping::map_inline_locations,
8-
LineMap,
9-
},
10-
model::{ListLevel, SectionLevel},
113
Admonition, AdmonitionVariant, Anchor, AttributeValue, Audio, Author, Autolink, Block,
124
BlockMetadata, Bold, Button, CurvedApostrophe, CurvedQuotation, DelimitedBlock,
135
DelimitedBlockType, DiscreteHeader, Document, DocumentAttribute, DocumentAttributes, Error,
@@ -16,6 +8,14 @@ use crate::{
168
PageBreak, Paragraph, Pass, PassthroughKind, Plain, Raw, Section, Source,
179
StandaloneCurvedApostrophe, Subscript, Substitution, Superscript, Table, TableColumn,
1810
TableOfContents, TableRow, ThematicBreak, UnorderedList, Url, Video,
11+
error::Detail,
12+
grammar::{
13+
LineMap,
14+
author_revision::{RevisionInfo, generate_initials, process_revision_info},
15+
inline_processing::{parse_inlines, preprocess_inline_content, process_inlines},
16+
location_mapping::map_inline_locations,
17+
},
18+
model::{ListLevel, SectionLevel},
1919
};
2020

2121
#[derive(Debug)]
@@ -2508,5 +2508,4 @@ Lorn_Kismet R. Lee <kismet@asciidoctor.org>; Norberto M. Lopes <nlopesml@gmail.c
25082508
assert!(metadata.options.contains(&"read".to_string()));
25092509
assert!(metadata.options.contains(&"write".to_string()));
25102510
}
2511-
25122511
}

acdc-parser/src/grammar/inline_processing.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::{
2-
inline_preprocessing, Error, InlineNode, InlinePreprocessorParserState, Location,
3-
ProcessedContent,
2+
Error, InlineNode, InlinePreprocessorParserState, Location, ProcessedContent,
3+
inline_preprocessing,
44
};
55

6-
use super::document::{document_parser, BlockParsingMetadata, ParserState, Position};
6+
use super::document::{BlockParsingMetadata, ParserState, Position, document_parser};
77

88
#[tracing::instrument(skip_all, fields(?start, ?content_start, end, offset))]
99
pub(crate) fn preprocess_inline_content(
@@ -67,6 +67,7 @@ pub(crate) fn process_inlines(
6767
let (initial_location, location, processed) =
6868
preprocess_inline_content(state, start, content_start, end, offset, content)?;
6969
let content = parse_inlines(&processed, block_metadata)?;
70-
let content = super::location_mapping::map_inline_locations(state, &processed, &content, &location);
70+
let content =
71+
super::location_mapping::map_inline_locations(state, &processed, &content, &location);
7172
Ok((content, initial_location))
72-
}
73+
}

acdc-parser/src/grammar/location_mapping.rs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::{
2-
InlineNode, Location, Plain, ProcessedContent,
3-
};
1+
use crate::{InlineNode, Location, Plain, ProcessedContent};
42

53
use super::document::ParserState;
64

@@ -19,11 +17,8 @@ pub(crate) fn map_bold_text_locations(
1917
) -> crate::Bold {
2018
// Map outer location with attribute extension
2119
let mapped_outer = map_loc(&bold_text.location);
22-
let extended_location = extend_attribute_location_if_needed(
23-
mapping_ctx.state,
24-
mapping_ctx.processed,
25-
mapped_outer
26-
);
20+
let extended_location =
21+
extend_attribute_location_if_needed(mapping_ctx.state, mapping_ctx.processed, mapped_outer);
2722
bold_text.location = extended_location;
2823

2924
// Map inner content locations
@@ -47,11 +42,8 @@ pub(crate) fn map_italic_text_locations(
4742
) -> crate::Italic {
4843
// Map outer location with attribute extension
4944
let mapped_outer = map_loc(&italic_text.location);
50-
let extended_location = extend_attribute_location_if_needed(
51-
mapping_ctx.state,
52-
mapping_ctx.processed,
53-
mapped_outer
54-
);
45+
let extended_location =
46+
extend_attribute_location_if_needed(mapping_ctx.state, mapping_ctx.processed, mapped_outer);
5547
italic_text.location = extended_location;
5648

5749
// Map inner content locations
@@ -192,7 +184,10 @@ pub(crate) fn map_inner_content_locations(
192184
.map(|node| match node {
193185
InlineNode::PlainText(mut inner_plain) => {
194186
// Replace passthrough placeholders in the content
195-
let content = super::passthrough_processing::replace_passthrough_placeholders(&inner_plain.content, processed);
187+
let content = super::passthrough_processing::replace_passthrough_placeholders(
188+
&inner_plain.content,
189+
processed,
190+
);
196191
inner_plain.content = content;
197192

198193
// Map to document coordinates first (use normal location mapping for inner content)
@@ -209,11 +204,7 @@ pub(crate) fn map_inner_content_locations(
209204
processed,
210205
base_location,
211206
};
212-
let mapped = map_italic_text_locations(
213-
italic_text,
214-
map_loc,
215-
&mapping_ctx,
216-
);
207+
let mapped = map_italic_text_locations(italic_text, map_loc, &mapping_ctx);
217208
InlineNode::ItalicText(mapped)
218209
}
219210
InlineNode::BoldText(bold_text) => {
@@ -223,19 +214,14 @@ pub(crate) fn map_inner_content_locations(
223214
processed,
224215
base_location,
225216
};
226-
let mapped = map_bold_text_locations(
227-
bold_text,
228-
map_loc,
229-
&mapping_ctx,
230-
);
217+
let mapped = map_bold_text_locations(bold_text, map_loc, &mapping_ctx);
231218
InlineNode::BoldText(mapped)
232219
}
233220
other => other,
234221
})
235222
.collect()
236223
}
237224

238-
239225
/// Remap the location of an inline node to final document coordinates
240226
pub(crate) fn remap_inline_node_location(node: &mut InlineNode, base_offset: usize) {
241227
match node {
@@ -443,4 +429,4 @@ pub(crate) fn map_inline_locations(
443429
other => vec![other.clone()],
444430
})
445431
.collect::<Vec<_>>()
446-
}
432+
}

acdc-parser/src/grammar/markup_patterns.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,10 @@ pub(crate) fn find_monospace_constrained_pattern(text: &str) -> Option<MarkupMat
383383
}
384384

385385
// Check if this might be a curved quote pattern - skip if so
386-
if i + 1 < chars.len()
387-
&& (chars[i + 1] == '"' || chars[i + 1] == '\'') {
388-
i += 1;
389-
continue;
390-
}
386+
if i + 1 < chars.len() && (chars[i + 1] == '"' || chars[i + 1] == '\'') {
387+
i += 1;
388+
continue;
389+
}
391390

392391
i += 1; // Skip the opening `
393392
let content_start = i;
@@ -646,4 +645,4 @@ mod tests {
646645
let result = find_curved_apostrophe_pattern("Use '`text with spaces`' here.");
647646
assert!(result.is_none());
648647
}
649-
}
648+
}

acdc-parser/src/grammar/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ mod markup_patterns;
77
mod passthrough_processing;
88
mod position_tracker;
99

10-
pub(crate) use document::{document_parser, ParserState};
10+
pub(crate) use document::{ParserState, document_parser};
1111
pub(crate) use inline_preprocessor::{
12-
inline_preprocessing, InlinePreprocessorParserState, ProcessedContent,
12+
InlinePreprocessorParserState, ProcessedContent, inline_preprocessing,
1313
};
1414
pub(crate) use position_tracker::{LineMap, PositionTracker};

acdc-parser/src/grammar/passthrough_processing.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
use crate::{
2-
InlineNode, Location, Pass, Plain, ProcessedContent, Substitution,
3-
};
1+
use crate::{InlineNode, Location, Pass, Plain, ProcessedContent, Substitution};
42

53
use super::{
64
document::ParserState,
75
location_mapping::remap_inline_node_location,
86
markup_patterns::{
9-
find_constrained_bold_pattern, find_curved_apostrophe_pattern, find_curved_quotation_pattern,
10-
find_highlight_constrained_pattern, find_highlight_unconstrained_pattern,
11-
find_italic_pattern, find_monospace_constrained_pattern, find_monospace_unconstrained_pattern,
7+
MarkupMatch, find_constrained_bold_pattern, find_curved_apostrophe_pattern,
8+
find_curved_quotation_pattern, find_highlight_constrained_pattern,
9+
find_highlight_unconstrained_pattern, find_italic_pattern,
10+
find_monospace_constrained_pattern, find_monospace_unconstrained_pattern,
1211
find_subscript_pattern, find_superscript_pattern, find_unconstrained_bold_pattern,
13-
find_unconstrained_italic_pattern, MarkupMatch,
12+
find_unconstrained_italic_pattern,
1413
},
1514
};
1615
use crate::{
@@ -545,7 +544,10 @@ pub(crate) fn merge_adjacent_plain_text_nodes(nodes: Vec<InlineNode>) -> Vec<Inl
545544
result
546545
}
547546

548-
pub(crate) fn replace_passthrough_placeholders(content: &str, processed: &ProcessedContent) -> String {
547+
pub(crate) fn replace_passthrough_placeholders(
548+
content: &str,
549+
processed: &ProcessedContent,
550+
) -> String {
549551
let mut result = content.to_string();
550552

551553
// Replace each passthrough placeholder with its content
@@ -557,4 +559,4 @@ pub(crate) fn replace_passthrough_placeholders(content: &str, processed: &Proces
557559
}
558560

559561
result
560-
}
562+
}

acdc-parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(crate) mod grammar;
4242
mod model;
4343
mod preprocessor;
4444

45-
pub(crate) use grammar::{inline_preprocessing, InlinePreprocessorParserState, ProcessedContent};
45+
pub(crate) use grammar::{InlinePreprocessorParserState, ProcessedContent, inline_preprocessing};
4646
use preprocessor::Preprocessor;
4747

4848
pub use error::{Detail as ErrorDetail, Error};

acdc-parser/src/model/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::collections::BTreeMap;
22

33
use serde::{
4+
Deserialize, Serialize,
45
de::Deserializer,
56
ser::{SerializeMap, Serializer},
6-
Deserialize, Serialize,
77
};
88

99
#[derive(Debug, Default, PartialEq, Clone)]

0 commit comments

Comments
 (0)