plurimath / plurimath.github.io

Official Plurimath web site
https://www.plurimath.org/
MIT License
0 stars 0 forks source link

"Functions" section should be generated via the `plurimath` gem directly #32

Open ronaldtse opened 3 months ago

ronaldtse commented 3 months ago

We can directly use the plurimath library to generate per symbol YAML files used to render this page through the Jekyll Data functionality.

e.g. the https://www.plurimath.org/functions/abs/ page can be generated using:

Rakefile:

directory '_data/functions/'

generate_functions_subtasks = []
Plurimath::Symbols.each do |s|
  filename = "_data/functions/#{s.name}.yaml"
  h = {
    "function_name": s.name,
    "type": s.type,
    "description": s.description,
    "asciimath": s.example_formula.to_asciimath,
    "latexmath": s.example_formula.to_latex,
    "mathml": s.example_formula.to_mathml,
    "omml": s.example_formula.to_omml,
  }
  File.write(filename, h.to_yaml)
  generate_functions_subtasks << filename
end

task generate_functions: generate_functions_subtasks

abs.yaml:

---
function_name: abs
type: unary
description: "The absolute value function (https://en.wikipedia.org/wiki/Absolute_value)."
asciimath: abs(x)
latex: "\abs{x}"
mathml: |
  <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
    <mstyle displaystyle="true">
      <mrow>
        <mo>|</mo>
        <mi>x</mi>
        <mo>|</mo>
      </mrow>
    </mstyle>
  </math>
omml: |
  <m:oMathPara>
    <m:oMath>
      <m:d>
        <m:dPr>
          <w:rPr>
            <w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
          </w:rPr>
          <m:begChr m:val="|"/>
          <m:endChr m:val="|"/>
          <m:sepChr m:val=""/>
          <m:grow/>
        </m:dPr>
        <m:e>
          <m:r>
            <m:t>x</m:t>
          </m:r>
        </m:e>
      </m:d>
    </m:oMath>
  </m:oMathPara>