Crate mtif

Source
Expand description

§Movable Type Import Format Parser

use mtif::{MTIFParser, MTIFEntry};

let parser = MTIFParser::new();
let contents = std::fs::read_to_string("./example/example.txt").unwrap();
let entries = parser.parse(&contents).unwrap();
dbg!(entries);

Output:

[
	MTIFEntry {
		metadata: MetaData {
				author: Some(
						"Foo Bar",
				),
				title: Some(
						"A dummy title",
				),
				basename: Some(
						"a-dummy-title",
				),
				status: None,
				allow_comments: None,
				allow_pings: None,
				convert_breaks: None,
				primary_category: Some(
						"Media",
				),
				category: [
						"News",
				],
				date: 2002-01-31 15:31:05.0,
				no_entry: false,
				tags: [],
				image: None,
		},
		body: Some(
				"This is the body.\n\nAnother paragraph here.\n\nAnother paragraph here.",
		),
		extended_body: Some(
				"Here is some more text.\n\nAnother paragraph here.\n\nAnother paragraph here.",
		),
		excerpt: None,
		keywords: None,
		comments: [
				Comment {
						author: Some(
								"Foo",
						),
						email: None,
						url: None,
						ip: None,
						date: Some(
								2002-01-31 15:47:06.0,
						),
						text: "This is\nthe body of this comment.",
				},
				Comment {
						author: Some(
								"Bar",
						),
						email: Some(
								"me@bar.com",
						),
						url: None,
						ip: Some(
								"205.66.1.32",
						),
						date: Some(
								2002-02-01 4:02:07.0,
						),
						text: "This is the body of\nanother comment. It goes\nup to here.",
				},
		],
		pings: [
				Ping {
						title: Some(
								"My Entry",
						),
						url: Some(
								"http://www.foo.com/old/2002/08/",
						),
						ip: Some(
								"206.22.1.53",
						),
						date: Some(
								2002-08-05 16:09:12.0,
						),
						blog_name: Some(
								"My Weblog",
						),
						text: "This is the start of my\nentry, and here it...",
				},
		],
	},
	MTIFEntry {
		metadata: MetaData {
				author: Some(
						"Baz Quux",
				),
				title: Some(
						"Here is a new entry",
				),
				basename: Some(
						"here-is-a-new-entry",
				),
				status: None,
				allow_comments: None,
				allow_pings: None,
				convert_breaks: None,
				primary_category: None,
				category: [
						"Politics",
				],
				date: 2002-01-31 3:31:05.0,
				no_entry: false,
				tags: [],
				image: None,
		},
		body: Some(
				"This is the body of the second entry. It can\nconsist of multiple lines.",
		),
		extended_body: None,
		excerpt: Some(
				"See, this entry does not have an extended piece; but\nit does have an excerpt. It is special.",
		),
		keywords: None,
		comments: [
				Comment {
						author: Some(
								"Quux",
						),
						email: None,
						url: Some(
								"http://www.quux.com/",
						),
						ip: None,
						date: Some(
								2002-01-31 16:23:01.0,
						),
						text: "Here is the first comment on this entry.",
				},
		],
		pings: [],
	},
]

Re-exports§

pub use model::MTIFEntry;

Modules§

model

Structs§

MTIFParser