Skip to content

Commit cc340ef

Browse files
committed
[chore] rust fmt
1 parent abcbdf7 commit cc340ef

File tree

12 files changed

+1113
-395
lines changed

12 files changed

+1113
-395
lines changed

crates/quarto-markdown-pandoc/src/pandoc/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::pandoc::caption::Caption;
1010
use crate::pandoc::inline::Inlines;
1111
use crate::pandoc::list::ListAttributes;
1212
use crate::pandoc::location::Range;
13-
use crate::pandoc::location::SourceLocation;
1413
use crate::pandoc::location::SourceInfo;
14+
use crate::pandoc::location::SourceLocation;
1515
use crate::pandoc::location::node_source_info;
1616
use crate::pandoc::table::Table;
1717

crates/quarto-markdown-pandoc/src/pandoc/inline.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::impl_source_location;
77
use crate::pandoc::attr::{Attr, is_empty_attr};
88
use crate::pandoc::block::Blocks;
99
use crate::pandoc::location::Range;
10-
use crate::pandoc::location::SourceLocation;
1110
use crate::pandoc::location::SourceInfo;
11+
use crate::pandoc::location::SourceLocation;
1212
use crate::pandoc::location::node_source_info;
1313
use crate::pandoc::shortcode::Shortcode;
1414

@@ -323,7 +323,12 @@ pub fn is_empty_target(target: &Target) -> bool {
323323
target.0.is_empty() && target.1.is_empty()
324324
}
325325

326-
pub fn make_span_inline(attr: Attr, target: Target, content: Inlines, source_info: SourceInfo) -> Inline {
326+
pub fn make_span_inline(
327+
attr: Attr,
328+
target: Target,
329+
content: Inlines,
330+
source_info: SourceInfo,
331+
) -> Inline {
327332
// non-empty targets are never Underline or SmallCaps
328333
if !is_empty_target(&target) {
329334
return Inline::Link(Link {
@@ -392,7 +397,12 @@ pub fn make_span_inline(attr: Attr, target: Target, content: Inlines, source_inf
392397
});
393398
}
394399

395-
pub fn make_cite_inline(attr: Attr, target: Target, content: Inlines, source_info: SourceInfo) -> Inline {
400+
pub fn make_cite_inline(
401+
attr: Attr,
402+
target: Target,
403+
content: Inlines,
404+
source_info: SourceInfo,
405+
) -> Inline {
396406
// the traversal here is slightly inefficient because we need
397407
// to non-destructively check for the goodness of the content
398408
// before deciding to destructively create a Cite

crates/quarto-markdown-pandoc/src/pandoc/location.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ impl SourceInfo {
3232
}
3333

3434
pub fn with_range(range: Range) -> Self {
35-
SourceInfo { filename: None, range }
35+
SourceInfo {
36+
filename: None,
37+
range,
38+
}
3639
}
3740

3841
pub fn combine(&self, other: &SourceInfo) -> SourceInfo {

crates/quarto-markdown-pandoc/src/pandoc/meta.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ impl MarkedEventReceiver for YamlEventHandler {
100100
match ev {
101101
Event::StreamStart | Event::DocumentStart => {}
102102
Event::MappingStart(..) => {
103-
self.stack.push(ContextFrame::Map(LinkedHashMap::new(), None));
103+
self.stack
104+
.push(ContextFrame::Map(LinkedHashMap::new(), None));
104105
}
105106
Event::MappingEnd => {
106107
if let Some(ContextFrame::Map(map, _)) = self.stack.pop() {
@@ -155,7 +156,19 @@ pub fn parse_metadata_strings(meta: MetaValue, outer_metadata: &mut Meta) -> Met
155156
match meta {
156157
MetaValue::MetaString(s) => {
157158
let mut output_stream = VerboseOutput::Sink(io::sink());
158-
let result = readers::qmd::read(s.as_bytes(), false, "<metadata>", &mut output_stream, None::<fn(&[u8], &crate::utils::tree_sitter_log_observer::TreeSitterLogObserver, &str) -> Vec<String>>);
159+
let result = readers::qmd::read(
160+
s.as_bytes(),
161+
false,
162+
"<metadata>",
163+
&mut output_stream,
164+
None::<
165+
fn(
166+
&[u8],
167+
&crate::utils::tree_sitter_log_observer::TreeSitterLogObserver,
168+
&str,
169+
) -> Vec<String>,
170+
>,
171+
);
159172
match result {
160173
Ok(mut pandoc) => {
161174
for (k, v) in pandoc.meta.into_iter() {

crates/quarto-markdown-pandoc/src/pandoc/treesitter.rs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,38 @@ fn process_backslash_escape(
470470
// Pandoc's default abbreviations list
471471
// From Text.Pandoc.Parsing in pandoc source
472472
fn is_abbreviation(text: &str) -> bool {
473-
matches!(text,
474-
"Mr." | "Mrs." | "Ms." | "Capt." | "Dr." | "Prof." |
475-
"Gen." | "Gov." | "e.g." | "i.e." | "Sgt." | "St." |
476-
"vol." | "vs." | "Sen." | "Rep." | "Pres." | "Hon." |
477-
"Rev." | "Ph.D." | "M.D." | "M.A." | "p." | "pp." |
478-
"ch." | "chap." | "sec." | "cf." | "cp.")
473+
matches!(
474+
text,
475+
"Mr."
476+
| "Mrs."
477+
| "Ms."
478+
| "Capt."
479+
| "Dr."
480+
| "Prof."
481+
| "Gen."
482+
| "Gov."
483+
| "e.g."
484+
| "i.e."
485+
| "Sgt."
486+
| "St."
487+
| "vol."
488+
| "vs."
489+
| "Sen."
490+
| "Rep."
491+
| "Pres."
492+
| "Hon."
493+
| "Rev."
494+
| "Ph.D."
495+
| "M.D."
496+
| "M.A."
497+
| "p."
498+
| "pp."
499+
| "ch."
500+
| "chap."
501+
| "sec."
502+
| "cf."
503+
| "cp."
504+
)
479505
}
480506

481507
// Coalesce Str nodes that end with abbreviations with following words
@@ -497,9 +523,16 @@ fn coalesce_abbreviations(inlines: Vec<Inline>) -> (Vec<Inline>, bool) {
497523
if is_abbreviation(&current_text) {
498524
// Coalesce with following Space + Str until we hit a capital letter
499525
while j + 1 < inlines.len() {
500-
if let (Inline::Space(_), Inline::Str(next_str)) = (&inlines[j], &inlines[j + 1]) {
526+
if let (Inline::Space(_), Inline::Str(next_str)) =
527+
(&inlines[j], &inlines[j + 1])
528+
{
501529
// Stop before uppercase letters (potential sentence boundaries)
502-
if next_str.text.chars().next().map_or(false, |c| c.is_uppercase()) {
530+
if next_str
531+
.text
532+
.chars()
533+
.next()
534+
.map_or(false, |c| c.is_uppercase())
535+
{
503536
break;
504537
}
505538

@@ -2529,7 +2562,9 @@ fn merge_strs(pandoc: Pandoc) -> Pandoc {
25292562
if let Some(current) = current_str.take() {
25302563
result.push(Inline::Str(Str {
25312564
text: current,
2532-
source_info: current_source_info.take().unwrap_or_else(empty_source_info),
2565+
source_info: current_source_info
2566+
.take()
2567+
.unwrap_or_else(empty_source_info),
25332568
}));
25342569
}
25352570
result.push(inline);

0 commit comments

Comments
 (0)