Code Monkey home page Code Monkey logo

scigen.js's Introduction

# SciGen.js

NPM version Node CI Gitter

This project brings SciGen to JavaScript, both for Node and for the browser.

Try it here!

Usage

Node

import { scigen, scigenSave } from 'scigen'

const files = scigen(
  /* authors = */ ['Jeremy Stribling', 'Max Krohn', 'Dan Aguayo'], 
  /* avoid bibtex dependency = */ false)
console.log(files['paper.tex'])

scigenSave(
  /* directory = */ 'mydir', 
  /* authors = */ undefined, 
  /* avoid bibtex dependency = */ true)

Command Line

$ git clone [email protected]:davidpomerenke/scigen.js && cd scigen
$ node lib/cli.js --help
Usage: node cli.js --save [<directory>] [--authors "<author1>, <author2>, ..."] [--bibinlatex] [--silent]
    directory   all files (.tex, .eps, .cls, .bib, ...) will be saved here
    authors     list of the authors in the paper
    bibinlatex  avoids dependency on BibTex (useful especially for texlive.js)
    silent      skip info logging
$ node cli.js --save tmp --authors "Jeremy Stribling, Max Krohn, Dan Aguayo" --silent
$ cd tmp
$ pdflatex -interaction=nonstopmode paper.tex 
$ bibtex paper.aux
$ pdflatex -interaction=nonstopmode paper.tex
$ pdflatex -interaction=nonstopmode paper.tex
$ xdg-open paper.pdf

Browser

$ git clone [email protected]:davidpomerenke/scigen.js && cd scigen
$ npx webpack
$ python -m http.server -d docs
$ xdg-open http://localhost:8000

See also the TexLive.js Wiki.

Rule Compilation

The almost original rule files from the original SciGen project are found in rules/rules-original. They can be compiled to JSON by running perl rules/compile-rules.pl. The JSON files are required for running the module. They are already included in the module and only need to be re-compiled for applying changes in the original .in rule files.

Structure

  • src includes the main source code, written in ES2016.
  • lib is a transpilation of this source code to standard JavaScript. Use this for running and importing the module locally. It is also the code for the NPM module.
  • rules includes the context-free grammar to create the papers:
    • rules/rules-original contains the .in rules from the original SciGen project, only very slightly modified.
    • rules/rules-compiled contains the rules compiled to JSON. They can be compiled to JSON by running perl rules/compile-rules.pl. The JSON files are required for running the module.
  • docs does not contain the documentation but a working example of using the module in the browser. It uses TexLive.js.
    • docs/bundle.js is the browser code for the module. It is created from the src directory by running npx webpack.
    • docs/precompiled-figures is a dirty workaround for the figures (see limitations).

Limitations

  • Bibtex is not available for the browser (cf. here). An almost perfect workaround is implemented for the parameter --bibinlatex (or setting the second/third function parameter to true in Node, see the above examples).
  • Rendering diagrams and figures requires Ghostscript in the original SciGen project. Ghostscript is not available for the browser.
    • A good workaround would probably involve rewriting the original EPS rules in some format which is supported by TexLive.js (maybe SVG or TIKZ). As this module is aimed at the browser, the diagram and figure code production is not yet implemented in the JavaScript code.
    • A current, bad workaround is implemented in docs/index.html, where some out of 50 pre-compiled figures are loaded from docs/precompiled-figures. However, for an obscure reason Latex treats the diagrams differently than the other figures and layouts them in a very weird way. So diagrams are currently left out completely, which is very unsatisfactory.
    • For locally producing TEX and PDF files with figures and diagrams, use the original SciGen project with this unmerged fix or run git clone [email protected]:davidpomerenke/scigen.js && cd scigen/scigen-perl && perl make-latex.pl.
  • Works in Firefox Desktop & Mobile and in Chrome Mobile, but not in Chrome/Chromium Desktop. Cf. this issue with TexLive.js.

Motivation

The server-side code at the original SciGen website appears to be broken. The aim of this project is therefore to provide a more server-independent implementation.

scigen.js's People

Contributors

strib avatar

Watchers

James Cloos 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.