npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

html-formulae

v0.4.1

Published

Formula converter for HTML

Downloads

2

Readme

html-formulæ Build Status Code Climate Dependency Status

npm

html-formulae is a mini-language for describing mathematical formulas that compiles to HTML.

It is designed to be:

  • readable, say markdown for formulas;
  • lightweight, it should not take much to start using it in no time;
  • flexible, plain HTML entities and tags should be supported, too.

Some features (dashes, quotation marks, whitespace) also make html-formulae suitable for plain text.

Try it: http://eush77.github.io/html-formulae-app/

Example

\&forall;(x,y)\&isin;setR^2:␣␣[y>0.&.(x!=0.||.y=1)]<=>[\&exist;a>0:.a^x=y]

compiles down to:

&forall;(x,y)&isin;&#8477;<sup>2</sup>:&ensp;[y&gt;0&thinsp;&amp;&thinsp;(x&ne;0&thinsp;&or;&thinsp;y=1)]&thinsp;&hArr;&thinsp;[&exist;a&gt;0:&thinsp;a<sup>x</sup>=y]

∀(x,y)∈ℝ2: [y>0 & (x≠0 ∨ y=1)] ⇔ [∃a>0: ax=y]

Syntax

  1. \ escapes.
  2. ^ and '_' stand for superscript and subscript, TeX-style grouping ({}) is supported. Example: x^{x_0} is rendered as xx0.
  3. Newlines are autoencoded to <br/>.
  4. There is also some built-in logic that protects hyphens in compound words from being interpreted as minuses, same for TT and BB.
  5. Some characters come with some spacing around: <=>, =>, =<, <==>, ==>, ==<, ']]`.

The complete table of symbols:

Sequence | Description :----------------------------------------------------------------: | ----------- mbscriptAmbscriptZ, mbscriptambscriptz | Mathematical bold script letters: 퓐–퓩, 퓪–픃 setP, setN, setZ, setQ, setR, setC, setF | Abstract and common number sets: ℙ, ℕ, ℤ, ℚ, ℝ, ℂ, 픽 +, -, *, /, &&, ǀǀ, ! | Arithmetic and logical operators: +, −, ⋅, /, ∧, ∨, ¬ =, ==, <, <=, >, >=, !=, /=, ~, ~~, <<, >> | Comparison relations: =, ═, <, ≤, >, ≥, ≠, ≠, ∼, ≈, ≪, ≫ <=>, =>, =<, <==>, ==>, ==<, ǀ-, ǀ=, TT, BB | Inference relations and constants: ⇔, ⇒, ⇐, ⟺, ⟹, ⟸, ⊢, ⊨, ⊤, ⊥ <->, ->, <-, <-->, -->, <-- | Other arrows: ↔, →, ←, ⟷, ⟶, ⟵ ]], :=, =def= | “Let” and defining signs: ⊐, ≔, ≝ +-, -+, &amp;, oo | Various symbols: ±, ∓ &, ∞ ---, -- | Dashes (em-dash, en-dash): —, – ˋˋ, '', <<<, >>> | Quotation marks: “, ”, «, » ␣␣␣, ␣␣, . | Whitespace sequences: em-space, en-space, thin-space

Note: backticks, pipes and spaces in the table above are replaced with other similar-looking (visible) characters.

HTML

HTML is also supported, but must be properly escaped.

For example, \&forall; and \&exist; are rather commonly used entities, check the complete list.

Another example: \<b\>bold\</b\>.

API

htmlFormulae([options], code)

Compile code to HTML.

The function is curried with dyn-curry, so you can fix options and get the converter function back:

var converter = htmlFormulae(options);
converter(code); // -> HTML

options.wrap controls whether the output should be wrapped in a tag. null disables wrapping.

> htmlFormulae('2_2')
'2<sub>2</sub>'
> htmlFormulae({ wrap: 'p' }, '2_2')
'<p>2<sub>2</sub></p>'

| Option | Type | Required? | Default | | :------| :----- | :-------: | :------ | | wrap | string | No | null |

CLI

html-formulae comes with a simple CLI.

Usage:  html-formulae [-w <tagname> | --wrap <tagname>]

Install

npm install html-formulae

License

MIT