Skip to main content
← OpenMECP Documentation

filter_tail_content

Function filter_tail_content 

Source
pub fn filter_tail_content(raw_content: &str) -> String
Expand description

Filters comments and cleans tail section content.

This function processes raw tail section content by:

  • Removing lines that start with ‘#’ (full-line comments)
  • Removing inline comments (text after ‘#’ on the same line as valid keywords)
  • Trimming leading and trailing whitespace from remaining lines
  • Joining valid lines with single spaces
  • Removing empty lines after trimming

§Arguments

  • raw_content - The raw tail section content that may contain comments

§Returns

A cleaned string containing only valid Gaussian keywords separated by spaces

§Examples

use omecp::parser::filter_tail_content;

let input = "# This is a comment\nTD(NStates=5)\n# Another comment\nRoot=1";
let result = filter_tail_content(input);
assert_eq!(result, "TD(NStates=5) Root=1");

// Inline comments are also removed
let inline = "TD(NStates=5) # inline comment\nRoot=1 # another comment";
let result = filter_tail_content(inline);
assert_eq!(result, "TD(NStates=5) Root=1");