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

This commit is contained in:
Tom Alexander 2023-12-21 12:07:36 -05:00
parent b538750287
commit 5654c40d03
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 7 additions and 4 deletions

View File

@ -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>

View File

@ -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(),
})
});

View File

@ -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 })
}
);