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"> <div class="src_block">
<!-- TODO: Get the language from the render context. --> {?.language}<div class="src_language">{.language}</div>{/.language}
<div class="src_language">text</div> <table class="src_body">
<table class="src_body">
<tbody> <tbody>
{#.lines} {#.lines}
<tr> <tr>

View File

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

View File

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