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

scigen

v0.2.1

Published

Create scientific papers on the fly: SciGen brought to the browser and to Node.

Downloads

17

Readme

# 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"],
  useBibtex: false,
});
// this returns an object of file names and contents
console.log(Object.keys(files));
console.log(files["paper.tex"]);

// or, to directly save the files to an actual directory:
scigenSave({
  directory: "mydir",
  authors: undefined,
  useBibtex: true,
});

Command Line

$ git clone [email protected]:davidpomerenke/scigen.js --depth 1 && 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
    useBibtex   use Bibtex for formatting the bibliography (disable this for use with texlive.js)
    silent      skip info logging
$ node lib/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

For the detailed setup with TexLive.js, have a look at the docs folder, where the demo is contained. 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.

Also interesting

Here's an interesting paper on the topic of scientific fake text generators.

  • Guillaume Cabanac, Cyril Labbé, Alexander Magazinov. Tortured phrases: A dubious writing style emerging in science. Evidence of critical issues affecting established journals. 2021. [arXiv]