GithubHelp home page GithubHelp logo

sano-jin / bussproofs-html Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 9.28 MB

Proof tree renderer on HTML, which can be used with KaTeX.

Home Page: https://sano-jin.github.io/bussproofs-html/

License: MIT License

HTML 15.97% TypeScript 73.45% CSS 7.99% JavaScript 2.03% Shell 0.57%
html katex latex proof-tree bussproofs markdown

bussproofs-html's Introduction

bussproofs-html

A JavaScript engine to render bussproofs style proof tree in html.

Note

  • Only proof trees directly under p elements are rendered.
  • Only \RightLabel can be used for a label for now.
  • Only \AXC, \UIC, \BIC, \TIC, and \QuaternaryInfC are allowed as a constcutor of the node of a proof tree.
  • \normalsize, \small, \footnotesize, \scriptsize, and \tiny are ignored.
  • No other LaTeX commands are allowed.

Send me PRs if you enable others.

How to use:

HTML

You can use this engine by adding a script tag as follows:

<script type="module">
  import { renderProofTreesOnLoad } from "https://sano-jin.github.io/bussproofs-html/assets/prooftree.js";
  renderProofTreesOnLoad();
</script>

Note

CSS class names starting from bussproofs-html__ are reserved.

markdown-preview.nvim

I forked markdown-preview.nvim and integrated this rendering engine. Here is the forked previewer. If you are using Lazy as a plugin manager, you can use the previewer as follows:

-- Lazy
  {
    "sano-jin/markdown-preview.nvim",
    cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
    build = "cd app && yarn install",
    init = function()
      vim.g.mkdp_filetypes = { "markdown" }
    end,
    ft = { "markdown" },
  },

Marp

You can use this engine by adding a script tag as follows:

---
marp: true
math: katex
paginate: true
footer: https://github.com/sano-jin/bussproofs-html
---

# Integration with Marp is easy!

Here comes a proof tree:
\begin{prooftree}
\AXC{$1 + 2$}
\AXC{$1 + 2 + 3$}
\BIC{$1 + 2$}
\AXC{$1 + 2 + 3$}
\RightLabel{Label}
\BIC{$1 + 2 + 3 + 4$}
\end{prooftree}

<script type="module">
  import { renderProofTreesOnLoad } from "https://sano-jin.github.io/bussproofs-html/assets/prooftree.js";
  renderProofTreesOnLoad();
</script>

VSCode

I'm not familiar with VSCode so I have not yet considered any integration plan. Please send me PR if you made any progress.

Configration options

You can pass configration options configP to renderProofTreesOnLoad and renderProofTrees.

interface configP {
  // the margin between premises (default is 20).
  marginPremises?: number;

  // the left and right padding of an axiom and conclusion (default is 20).
  paddingAxiomConclusion?: number;

  // the left margin of a label (default is 10).
  marginLabelLeft?: number;

  // when to apply styles; after load (on null) or manually set timeout (on number) (default is null).
  styleOnLoad?: null | number;
}

For example, if you specify the configration as follows, the margin between premises will be 100px, the left and right padding of an axiom and conclusion will be 0px, the left margin of a label will be 0px, and the style will be applied after 100 milliseconds.

renderProofTreesOnLoad({
  marginPremises: 100,
  paddingAxiomConclusion: 0,
  marginLabelLeft: 0,
  styleOnLoad: 100,
});

For developpers: how to build

Develop:

cd proof-tree
yarn dev
# access the displayed url on your browser.

Deploy:

cd proof-tree
yarn build
cd ..
cp proof-tree/dist/index.js docs/assets/prooftree.js

Roadmap

I have a folloing roadmap. Please send me PR if you made any progress.

  1. Enable \LeftLabel.
  2. Add VSCode integration.
  3. Make the styling process robust.
    • To style a proof tree, the width of the nodes of the proof tree are obtained after the first HTML rendering.
    • Currently, we have two options for timing the styling:
      • A: style after the load event or
      • B: style after user-specified milliseconds after the insertion of the DOM elements of a proof tree.
    • (B) Styling after user-specified milliseconds is not a robust way since we cannot precisely predict how long does it take to render the inserted DOM elements. If we try to style before the completion of the rendering, we cannot get an expected result.
    • (A) Styling after load event, which is fired after DOM contents are fully rendered in my understanding, is a more robust method and it should work. However, in some cases it seems not to work: e.g., in the integration with markdown-preview.nvim. A deeper and more comprehensive understanding is needed.
  4. Release the first version.

bussproofs-html's People

Contributors

sano-jin avatar

Stargazers

SnO₂WMaN avatar Qirui Wang avatar Kento Takyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.