Skip to content
neo API reference
NeoScript

neo API reference

All functions of NeoScript's neo object, by group, with what each one does, where it works and complete examples.

On this page

The global neo object groups the API by subject. All functions are synchronous and throw exceptions on error. Those that touch the disk only accept paths inside the allowed folders. In the examples, C:/Equacoes stands for a folder you allowed.

Equation#

Function What it does
neo.equacao.latex() returns the LaTeX of the current tab’s equation
neo.equacao.mathml() returns the MathML of the current tab’s equation
neo.equacao.definir(texto) replaces the whole equation with LaTeX or MathML (one undo step)
neo.equacao.limpar() empties the equation
neo.equacao.vazia() tells whether the equation is empty
neo.equacao.selecionarTudo() selects the whole equation (useful before neo.cor)
neo.equacao.medidas() measures the equation in typographic points

Editing#

Function What it does
neo.inserir(texto) inserts at the cursor LaTeX, a palette item ("m:fracao"), a symbol or a matrix
neo.digitar(texto) types character by character, like the keyboard
neo.tecla(nome, vezes?) presses a navigation or editing key ("direita", "esquerda"…)
neo.desfazer() / neo.refazer() undo and redo
neo.estilo(nome) chooses the typing style
neo.cor(cor) paints the selection or what is typed next; null removes
neo.corCmyk(c, m, y, k) the same in CMYK, each ink from 0 to 100
neo.corEmTudo(valor?) turns color on or off for fraction bars, parentheses and radicals
neo.matriz.inserir(linhas, colunas, delimitador?, alinhamento?) inserts a matrix
neo.matriz.editar(op) edits the matrix where the cursor is

Export and convert#

Function What it does
neo.exportar(formato, caminho, opcoes?) writes the equation as "eps", "svg", "png", "mathml" or "latex"; { dpi, fundoBranco } for PNG
neo.converter.latexParaMathml(texto) LaTeX to MathML, without touching the editor
neo.converter.mathmlParaLatex(texto) MathML to LaTeX
neo.converter.arquivos(tipo, entrada, saida, opcoes?) converts files and folders between the types Neo understands, on a file or a folder
neo.lote(pasta, formato?, opcoes?) converts every formula in a folder to EPS, SVG or PNG
neo.lote.estilizar(pasta, opcoes) batch style; without aplicar: true it only simulates
neo.lote.desfazer(pasta, opcoes?) restores the originals from the last backup
neo.lote.backups(pasta) lists the batch style backups
neo.docx(arquivo, saida, formato?) extracts the equations of a .docx

Tabs#

Function What it does
neo.abas.listar() lists the open tabs
neo.abas.atual() / neo.abas.total() focused tab and count
neo.abas.nova() opens an empty tab, which becomes the current one
neo.abas.escolher(indice) switches tab
neo.abas.fechar(indice?) closes a tab (the last one is only emptied)

Files#

Function What it does
neo.arquivo.abrir(caminho) opens an equation in the current tab
neo.arquivo.salvar(caminho?) saves the equation as EPS
neo.arquivo.inspecionar(caminho) reads a NeoMath EPS, SVG or PNG without opening it
neo.arquivo.ler(caminho) / neo.arquivo.escrever(caminho, conteudo, anexar?) reads and writes text files
neo.arquivo.existe(caminho) / neo.arquivo.listar(pasta) checks and lists
neo.arquivo.criarPasta(pasta) / neo.arquivo.apagar(caminho) creates folders; deletes files (never folders)

Preferences, OCR and interface#

Function What it does
neo.preferencias.listar() / atual() / definir(nomeOuIndice) chooses the style preference
neo.preferencias.carregar(caminho) loads a style from a file
neo.ocr.reconhecer(imagem) recognizes the equation in an image and returns the LaTeX (app only)
neo.ocr.inserir(imagem) recognizes and inserts at the cursor (app only)
neo.acao(nome) triggers an interface action through the same path as the menu
neo.mensagem(texto, titulo?) shows a message (in a terminal, it goes to stderr)
neo.esperar(ms) pauses, respecting the Stop button
neo.versao, neo.script.nome, neo.script.pasta, neo.permissoes() environment information

Chemistry#

The neo.quimica group works with chemistry. The structure comes in as text: a SMILES or the content of a CML, MOL, SDF or CDML.

Function What it does
ler, propriedades, formula, massa summary, Hill formula, molar mass, counts and composition
layout 2D drawing (coordinates, rings, wedges)
converter(entrada, destino) / exportar(entrada, destino, caminho) SMILES, CML, MOL, SDF, JSON, SVG and PNG
verificar, explicar, descrever valence, disconnected parts, rules used and accessible description
relatorio(entrada, opcoes?) Markdown report for school work
abrir(caminho), lote(pasta, formato) structure files and whole folders
inserirFormula(entrada) inserts the formula (C₂H₆O) into the tab’s equation
reacao.ler, reacao.converter, reacao.exportar reaction schemes in text (2H2 + O2 -> 2H2O)
elemento(consulta), tabelaPeriodica() data for the 118 elements
catalogo.listar, pesquisar, estrutura, inserir catalog of ready-made structures

Examples#

Export a table of equations#

JavaScript
const pasta = "C:/Equacoes";
const formulas = {
  pitagoras: "a^2+b^2=c^2",
  bhaskara: "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}",
  euler: "e^{i\\pi}+1=0"
};
for (const nome in formulas) {
  neo.abas.nova();
  neo.equacao.definir(formulas[nome]);
  neo.exportar("svg", pasta + "/" + nome + ".svg");
  neo.exportar("png", pasta + "/" + nome + ".png", { dpi: 300, fundoBranco: true });
}
console.log("done:", neo.abas.total(), "tabs");

Convert a whole folder#

JavaScript
const r = neo.lote("C:/Equacoes/formulas", "eps", { saida: "C:/Equacoes/eps" });
console.log(r.ok + " of " + r.total + " converted");
r.falhas.forEach(f => console.warn(f.nome + ": " + f.erro));

Handle errors#

JavaScript
try {
  neo.equacao.definir("\\frac{");
} catch (e) {
  console.warn("could not read:", e.message);
}

Chemistry#

JavaScript
const p = neo.quimica.propriedades("CC(=O)Oc1ccccc1C(=O)O");
console.log(p.formula, p.massaMolar);
neo.quimica.exportar("c1ccccc1O", "png", "C:/Quimica/fenol", { dpi: 150, fundoBranco: true });

What exists in JavaScript#

All of standard JavaScript exists (Math, JSON, Date, RegExp, Map, Set, classes, Promise and async/await inside functions). import, require, fetch, XMLHttpRequest, WebSocket, process, window and document do not exist, nor does top-level await. The value of the script’s last expression is returned as the result.