Giter Site home page Giter Site logo

arxiv-vanity / engrafo Goto Github PK

View Code? Open in Web Editor NEW
1.1K 16.0 91.0 22.14 MB

Convert LaTeX documents into beautiful responsive web pages using LaTeXML.

Home Page: https://www.arxiv-vanity.com

License: Apache License 2.0

JavaScript 1.25% Shell 0.05% TeX 8.48% Dockerfile 0.05% HTML 89.57% Perl 0.06% SCSS 0.54%
latex academic-publishing science arxiv latexml

engrafo's Introduction

Engrafo

Engrafo converts LaTeX documents into beautiful responsive web pages using LaTeXML.

It is a set of stylesheets and scripts for LaTeXML output. It makes the design responsive so you can read it on phones, and adds various interactive bits like footnote tooltips.

It turns this sort of thing:

Into this:

Usage

The easiest way to run Engrafo is by using the Docker image. To convert input/main.tex into output/index.html, run:

$ docker run \
  -v "$(pwd)":/workdir -w /workdir \
  arxivvanity/engrafo engrafo input/main.tex output/

Input can be a TeX file, a directory containing a TeX file and supporting files, or a tarball containing a TeX file and supporting files.

Either input or output can be on S3 by using the form s3://bucket/path and setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

For full usage, run docker run arxivvanity/engrafo engrafo --help.

Server

Engrafo can also be run as an HTTP server, which is useful if you need to run it over a network.

$ docker run -e PORT=8000 -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -p 8000:8000 arxivvanity/engrafo engrafo-server
๐Ÿ’ƒ  Listening on http://0.0.0.0:8000

$ curl -X POST \
    -H 'Content-Type: application/json' \
    -d '{"input": "s3://some-bucket/source.tar.gz", "output": "s3://some-bucket/output/"}' \
    http://localhost:8000/convert
{
    "success": true,
    "logs": "..."
}

Development environment

First, install Node and Yarn. Then, install the Node dependencies:

$ yarn

Frontend development

For developing the CSS and frontend JavaScript, there are a bunch of pre-rendered documents you can use to work with. This means you don't need to install LaTeX or Docker.

Run this command:

$ yarn run storybook

Then, all the documents will be available as a Storybook at http://localhost:6006. Any changes you make to the CSS and JS in src/assets/ will automatically be updated in the Storybook.

Converting documents

The LaTeXML and LaTeX toolchain runs inside Docker. If you want to work on the code that actually converts documents, you will need to install Docker.

Install Docker and build the Docker image:

$ script/docker-build

You can convert documents with yarn run convert:

$ yarn run convert tests/documents/sample2e.tex output/

There is also a development server, which is useful for developing CSS and JavaScript. When you make changes to the JavaScript or CSS, it will automatically update in the browser:

$ yarn run dev-server tests/documents/sample2e.tex

There is a script to download a paper from arXiv and start a development server:

$ script/arxiv-dev-server 1707.08901

Tests

As a one-off, you will need to build the Docker image:

$ script/docker-build

This only needs running once, unless you change something in the build process (e.g. LaTeXML version). The code is mounted at run-time.

Run the main test suite:

$ yarn test

You can run particular suites:

$ yarn test tests/integration.test.js

Or particular tests by matching a string:

$ yarn test -t "titles and headings"

Writing integration tests

The integration tests are LaTeX documents in tests/integration that are rendered to ensure they produce a particular output. The HTML output from LaTeXML is checked using Jest snapshots, and the visual output is checked using Percy.

First, write a LaTeX document in tests/integration. If it is a test for a package, it normally has the same name as the package, as you can see from other documents in that directory.

For example, this could be a test in tests/integration/textbf.tex:

\begin{document}
  I am \textbf{bold}!
\end{document}

Now, run the test passing the -u option to write out a snapshot of what is rendered:

$ yarn test -t "textbf.tex" -u

Check the output looks correct in tests/__snapshots__/integration.test.js.snap. You can re-run that command without the -u option to ensure the test passes.

The test will fail if the output changes in the future. If the change is expected, then you can simply re-run the test with -u to overwrite the snapshot and fix the test.

The visual changes are harder to test locally. The easiest way is to open a pull request, then Percy will check for any changes against master.

Code style

All code must be formatted with Prettier. To automatically format the code, run:

$ yarn run prettier

Sponsors

Thanks to our generous sponsors for supporting the development of arXiv Vanity!

YLD

Tested by:

Percy

engrafo's People

Contributors

andreasjansson avatar bfirsh avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar isabroch avatar jkukul avatar ryanbloom avatar sadmear avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

engrafo's Issues

Fix widows in headings

screenshot 2017-07-31 19 04 12

The usual solution of adding   is causing a weird huge space, so this needs investigating. Maybe something wrong with the font?

Make stylesheets external & cacheable

Currently, everything is just injected into <head>, which is probably not ideal.

Also, let's not write CSS inside strings inside JavaScript. It's horrible.

Indents don't work

\indent just comes through as a normal paragraph. This should be wrapped in <blockquote>, or at least a <div>.

Table captions at top of table don't work

Works:

  \begin{table}[h]
    \begin{tabular}{c c} \toprule
      First column & Second column \\ \toprule
      123 & 456 \\
      234 & 567 \\
      567 & 890  \\
    \end{tabular}
    \caption{Some numbers.}
    \label{table:1}
  \end{table}

Doesn't:

  \begin{table}[h]
    \caption{Some numbers.}
    \begin{tabular}{c c} \toprule
      First column & Second column \\ \toprule
      123 & 456 \\
      234 & 567 \\
      567 & 890  \\
    \end{tabular}
    \label{table:1}
  \end{table}

This should probably be fixed in Pandoc, because that's the point where the label is added to a data-label attribute on the caption.

Only run Distill components that we actually use

Currently we do the brute force approach of running the whole of Distill against our stuff, even though we don't use a lot of it (bibliography, math, etc).

We should make a custom build of Distill that exposes components individually, and only call what needs calling.

Inline footnotes

Pandoc makes anchors and puts the footnotes at the bottom. Distill footnotes look like this:

<dt-fn>This will become a hoverable footnote.</dt-fn>

In theory, should be simpler, because this is how they are represented in Latex.

Make <h5> work

It isn't styled at all at the moment, and it probably shouldn't generate section numbers (1.1.1.1 is a bit much).

Support \def

Required for a bunch of papers to parse, e.g. 1608.08225v3

Abstracts?

Pandoc just swallows them right now. I think abstract should exist, just not sure where.

Put acknowledgements in Distill's appendix

If there is a heading called "acknowledgements" at the end, put it in . This miight be complicated if there is any block-level stuff in there because Distill doesn't apply formatting to its appendix. So, in that case, just skip it.

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.