natter/src/intermediate/src_block.rs

26 lines
569 B
Rust
Raw Normal View History

use super::macros::intermediate;
2023-10-29 22:31:29 -04:00
use crate::error::CustomError;
2023-10-27 17:08:58 -04:00
2023-10-29 15:36:15 -04:00
#[derive(Debug, Clone)]
pub(crate) struct ISrcBlock {
pub(crate) lines: Vec<String>,
pub(crate) language: Option<String>,
}
2023-10-27 17:08:58 -04:00
intermediate!(
ISrcBlock,
&'orig organic::types::SrcBlock<'parse>,
original,
_registry,
{
let lines = original
.get_value()
.split_inclusive('\n')
.map(|s| s.to_owned())
.collect();
let language = original.language.map(str::to_owned);
Ok(ISrcBlock { lines, language })
}
);