Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use as a pandoc filter plugin #51

Open
colindean opened this issue Feb 28, 2021 · 1 comment
Open

Use as a pandoc filter plugin #51

colindean opened this issue Feb 28, 2021 · 1 comment

Comments

@colindean
Copy link

It would be really awesome to be able to use CalcuLaTeX as a pandoc filter plugin.

A document might look something like this:

Given a rock with mass $m_{rock}$ thrown by a force of $F_0$ acting over a duration $dt_{force}$,
calculate its airtime and the max height it achieves.

Given:

~~~ {calculatex #eq:facts}
g = 9.81 m/s^2
m_{rock} = 10 kg
F_0 = 1000 N
dt_{force} = 0.1 s
~~~

Solution:

~~~ {calculatex #eq:velocity}
y_{vel} = F_0 / m_{rock} * dt_{force} = ?
~~~
~~~ {calculatex #eq:airtime}
airtime = y_{vel} / g * 2 = ?
~~~
~~~ {calculatex #eq:heightmax}
height_{max} = y_{vel} * airtime / 4 = ? cm
~~~

and the output would essentially be this:

Given a rock with mass $m_{rock}$ thrown by a force of $F_0$ acting over a duration $dt_{force}$,
calculate its airtime and the max height it achieves.

Given:

$$
g = 9.81 m/s^2
m_{rock} = 10 kg
F_0 = 1000 N
dt_{force} = 0.1 s
$$ {#eq:facts}

Solution:

$$
y_{vel} = F_0 / m_{rock} * dt_{force} = 10 m/s
$$ {#eq:velocity}

$$
airtime = y_{vel} / g * 2 = 2.039 s
$$ {#eq:airtime}

$$
height_{max} = y_{vel} * airtime / 4 = 5.097 m
$$  {#eq:heightmax}

Passing additional code block classes through to the generated equation block enables compatibility with pandoc-crossref, too.

It'd be assumed that the calculatex block creates one environment per document. However, I'll bet you could add some kind of class with a key-value attribute that can assign calculatex code blocks to a certain environment or clear the state of the default.

@colindean colindean changed the title Use as a pandoc plugin Use as a pandoc filter plugin Feb 28, 2021
@mkhan45
Copy link
Owner

mkhan45 commented Mar 1, 2021

This is a really good idea and seems like a great way for CalcuLaTeX to be used in research. I definitely want to do this but it'll have to wait for the core functionality to be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants