Compare commits
No commits in common. "5e476e189a945059e3e49b586ff0da31260de9a8" and "ada11816fbb350aa6def127cba1124142739361b" have entirely different histories.
5e476e189a
...
ada11816fb
@ -1,2 +1 @@
|
|||||||
{! TODO: Should I be including MathJax somewhere? !}
|
!!!!!!!! latex_fragment
|
||||||
{.value}
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
* Double dollar
|
|
||||||
#+begin_src org
|
|
||||||
$$CONTENTS$$
|
|
||||||
#+end_src
|
|
||||||
becomes
|
|
||||||
#+begin_src text
|
|
||||||
\[CONTENTS\]
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+begin_src org
|
|
||||||
$$1+1=2$$
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+begin_src text
|
|
||||||
\[1+1=2\]
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
This gets interpreted by mathjax.
|
|
||||||
* Single Dollar
|
|
||||||
#+begin_src org
|
|
||||||
PRE$BORDER1 BODY BORDER2$POST
|
|
||||||
#+end_src
|
|
||||||
becomes
|
|
||||||
#+begin_src text
|
|
||||||
\(BORDER1 BODY BORDER2\)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+begin_src org
|
|
||||||
foo$a bar b$.
|
|
||||||
#+end_src
|
|
||||||
becomes
|
|
||||||
#+begin_src text
|
|
||||||
foo\(a bar b\).
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
This gets interpreted by mathjax.
|
|
@ -6,11 +6,18 @@ use crate::config::Config;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::IComment;
|
use crate::intermediate::IComment;
|
||||||
|
|
||||||
use super::macros::rnoop;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "comment")]
|
#[serde(rename = "comment")]
|
||||||
pub(crate) struct RenderComment {}
|
pub(crate) struct RenderComment {}
|
||||||
|
|
||||||
rnoop!(RenderComment, IComment);
|
impl RenderComment {
|
||||||
|
pub(crate) fn new(
|
||||||
|
_config: &Config,
|
||||||
|
_output_directory: &Path,
|
||||||
|
_output_file: &Path,
|
||||||
|
_comment: &IComment,
|
||||||
|
) -> Result<RenderComment, CustomError> {
|
||||||
|
Ok(RenderComment {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,25 +6,18 @@ use crate::config::Config;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::ILatexFragment;
|
use crate::intermediate::ILatexFragment;
|
||||||
|
|
||||||
use super::macros::render;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "latex_fragment")]
|
#[serde(rename = "latex_fragment")]
|
||||||
pub(crate) struct RenderLatexFragment {
|
pub(crate) struct RenderLatexFragment {}
|
||||||
value: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
render!(
|
impl RenderLatexFragment {
|
||||||
RenderLatexFragment,
|
pub(crate) fn new(
|
||||||
ILatexFragment,
|
_config: &Config,
|
||||||
original,
|
_output_directory: &Path,
|
||||||
_config,
|
_output_file: &Path,
|
||||||
_output_directory,
|
_comment: &ILatexFragment,
|
||||||
_output_file,
|
) -> Result<RenderLatexFragment, CustomError> {
|
||||||
{
|
Ok(RenderLatexFragment {})
|
||||||
Ok(RenderLatexFragment {
|
}
|
||||||
value: original.value.clone(),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
/// Write the implementation for the render ast node.
|
|
||||||
///
|
|
||||||
/// This exists to make changing the type signature easier.
|
|
||||||
macro_rules! render {
|
|
||||||
($rstruct:ident, $istruct:ident, $original:ident, $config:ident, $output_directory:ident, $output_file:ident, $fnbody:tt) => {
|
|
||||||
impl $rstruct {
|
|
||||||
pub(crate) fn new(
|
|
||||||
config: &Config,
|
|
||||||
output_directory: &Path,
|
|
||||||
output_file: &Path,
|
|
||||||
original: &$istruct,
|
|
||||||
) -> Result<$rstruct, CustomError> {
|
|
||||||
let $original = original;
|
|
||||||
let $config = config;
|
|
||||||
let $output_directory = output_directory;
|
|
||||||
let $output_file = output_file;
|
|
||||||
$fnbody
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) use render;
|
|
||||||
|
|
||||||
/// Write the implementation for a render ast node that has no fields.
|
|
||||||
///
|
|
||||||
/// This exists to make changing the type signature easier.
|
|
||||||
macro_rules! rnoop {
|
|
||||||
($rstruct:ident, $istruct:ident) => {
|
|
||||||
impl $rstruct {
|
|
||||||
pub(crate) fn new(
|
|
||||||
_config: &Config,
|
|
||||||
_output_directory: &Path,
|
|
||||||
_output_file: &Path,
|
|
||||||
_original: &$istruct,
|
|
||||||
) -> Result<$rstruct, CustomError> {
|
|
||||||
Ok($rstruct {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) use rnoop;
|
|
@ -32,7 +32,6 @@ mod keyword;
|
|||||||
mod latex_environment;
|
mod latex_environment;
|
||||||
mod latex_fragment;
|
mod latex_fragment;
|
||||||
mod line_break;
|
mod line_break;
|
||||||
mod macros;
|
|
||||||
mod object;
|
mod object;
|
||||||
mod org_macro;
|
mod org_macro;
|
||||||
mod paragraph;
|
mod paragraph;
|
||||||
|
@ -1,19 +1,5 @@
|
|||||||
use super::macros::intermediate;
|
use super::macros::inoop;
|
||||||
|
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
inoop!(ILatexFragment, LatexFragment);
|
||||||
pub(crate) struct ILatexFragment {
|
|
||||||
pub(crate) value: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
intermediate!(ILatexFragment, LatexFragment, original, _registry, {
|
|
||||||
let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") {
|
|
||||||
format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)])
|
|
||||||
} else if original.value.starts_with("$") && original.value.ends_with("$") {
|
|
||||||
format!("\\({}\\)", &original.value[1..(original.value.len() - 1)])
|
|
||||||
} else {
|
|
||||||
original.value.to_owned()
|
|
||||||
};
|
|
||||||
Ok(ILatexFragment { value })
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user