Get the real language for src blocks from the org source.

main
Tom Alexander 4 months ago
parent b538750287
commit 5654c40d03
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -1,7 +1,6 @@
<div class="src_block">
<!-- TODO: Get the language from the render context. -->
<div class="src_language">text</div>
<table class="src_body">
{?.language}<div class="src_language">{.language}</div>{/.language}
<table class="src_body">
<tbody>
{#.lines}
<tr>

@ -11,10 +11,12 @@ use super::macros::render;
#[serde(rename = "src_block")]
pub(crate) struct RenderSrcBlock {
lines: Vec<String>,
language: Option<String>,
}
render!(RenderSrcBlock, ISrcBlock, original, _render_context, {
Ok(RenderSrcBlock {
lines: original.lines.clone(),
language: original.language.clone(),
})
});

@ -5,6 +5,7 @@ use crate::error::CustomError;
#[derive(Debug, Clone)]
pub(crate) struct ISrcBlock {
pub(crate) lines: Vec<String>,
pub(crate) language: Option<String>,
}
intermediate!(
@ -18,6 +19,7 @@ intermediate!(
.split_inclusive('\n')
.map(|s| s.to_owned())
.collect();
Ok(ISrcBlock { lines })
let language = original.language.map(str::to_owned);
Ok(ISrcBlock { lines, language })
}
);

Loading…
Cancel
Save