pub fn format_text(file_text: &str, config: &Configuration, format_code_block_text: impl FnMut(&str, &str, u32) -> Result<String>) -> Result<String> {
  let (source_file, markdown_text) = match parse_source_file(file_text, config)? {
    ParseFileResult::IgnoreFile => return Ok(file_text.to_string()),
    ParseFileResult::SourceFile(file) => file,
  };

  Ok(dprint_core::formatting::format(
    || {
      let mut context = Context::new(&markdown_text, config, format_code_block_text);
      let print_items = generate(&source_file.into(), &mut context);
      // println!("{}", print_items.get_as_text());
      print_items
    },
    config_to_print_options(file_text, config),
  ))
}
/// Formats a file.
///
/// Returns the file text or an error when it failed to parse.
Formats a file.
Returns the file text or an error when it failed to parse.
Formats a file . Returns the file text or an error when it failed to parse .
pub fn format_text(file_text: &str, config: &Configuration, format_code_block_text: impl FnMut(&str, &str, u32) -> Result<String>) -> Result<String> {
  let (source_file, markdown_text) = match parse_source_file(file_text, config)? {
    ParseFileResult::IgnoreFile => return Ok(file_text.to_string()),
    ParseFileResult::SourceFile(file) => file,
  };
  Ok(dprint_core::formatting::format(
    || {
      let mut context = Context::new(&markdown_text, config, format_code_block_text);
      let print_items = generate(&source_file.into(), &mut context);
      // println!("{}", print_items.get_as_text());
      print_items
    },
    config_to_print_options(file_text, config),
  ))
}
pub fn format_text ( file_text : & str , config : & Configuration , format_code_block_text : impl FnMut ( & str , & str , u32 ) -> Result < String > ) -> Result < String > { let ( source_file , markdown_text ) = match parse_source_file ( file_text , config ) ? { ParseFileResult :: IgnoreFile => return Ok ( file_text . to_string ( ) ) , ParseFileResult :: SourceFile ( file ) => file , } ; Ok ( dprint_core :: formatting :: format ( | | { let mut context = Context :: new ( & markdown_text , config , format_code_block_text ) ; let print_items = generate ( & source_file . into ( ) , & mut context ) ; // println!("{}", print_items.get_as_text()); print_items } , config_to_print_options ( file_text , config ) , ) ) }
Formats a file.
Formats a file .
file_text
&str
config
&Configuration
format_code_block_text
impl FnMut(&str, &str, u32) -> Result<String>
file_text
&str
config
&Configuration
format_code_block_text
impl FnMut(&str, &str, u32) -> Result<String>