Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rootstock 2020 11 11 #62

Merged
merged 6 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/manubot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
restore-keys: |
ci-cache-refs/heads/master
- name: Install Environment
uses: goanpeca/setup-miniconda@v1
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: manubot
environment-file: build/environment.yml
Expand Down
12 changes: 7 additions & 5 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,32 @@ To change the options, either edit the YAML files directly or add additional `--

Note: currently, **Windows is not supported**.

Install the [conda](https://conda.io) environment specified in [`environment.yml`](environment.yml) by running the following commands from this directory:
Install the [conda](https://conda.io) environment specified in [`environment.yml`](environment.yml) by running the following commands
(from the repository's root directory):

```sh
# Install the environment
conda env create --file environment.yml
conda env create --file build/environment.yml
```

If the `manubot` environment is already installed, but needs to be updated to reflect changes to `environment.yml`, use one of the following options:

```shell
# option 1: update the existing environment.
conda env update --file environment.yml
conda env update --file build/environment.yml

# option 2: remove and reinstall the manubot environment.
# Slower than option 1, but guarantees a fresh environment.
conda env remove --name manubot
conda env create --file environment.yml
conda env create --file build/environment.yml
```

Activate with `conda activate manubot` (assumes `conda` version of [at least](https://github.com/conda/conda/blob/9d759d8edeb86569c25f6eb82053f09581013a2a/CHANGELOG.md#440-2017-12-20) 4.4).
The environment should successfully install on both Linux and macOS.
However, it will fail on Windows due to the [`pango`](https://anaconda.org/conda-forge/pango) dependency.

Because the build process is dependent on having the appropriate version of the `manubot` Python package, it is necessary to use the version specified in `environment.yml`.
Because the build process is dependent on having the appropriate version of the `manubot` Python package,
it is necessary to use the version specified in `environment.yml`.
The latest `manubot` release on PyPI may not be compatible with the latest version of this rootstock repository.

## Building PDFs
Expand Down
25 changes: 14 additions & 11 deletions build/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@ dependencies:
- jinja2=2.11.2
- jsonschema=3.2.0
- pandoc=2.9.2
- panflute=1.12.5
- pango=1.40.14
- pip=20.0
- psutil=5.7.0
- python=3.7.6
- pip=20.2
- psutil=5.7.3
- python=3.7.8
- pyyaml=5.3
- requests=2.23.0
- watchdog=0.10.2
- yamllint=1.21.0
- requests=2.24.0
- toml=0.10.2
- watchdog=0.10.3
- yamllint=1.25.0
- pip:
- errorhandler==2.0.1
- git+https://github.com/manubot/manubot@31968197d1ccd96a46bf092cdba4b575764bb954
- git+https://github.com/manubot/manubot@7c03b4a7d42506b3241e58cd5643a028443b9b9d
- isbnlib==3.10.3
- opentimestamps-client==0.7.0
- opentimestamps==0.4.1
- pandoc-eqnos==2.1.1
- pandoc-fignos==2.2.0
- pandoc-tablenos==2.1.1
- pandoc-xnos==2.2.0
- pandoc-eqnos==2.3.0
- pandoc-fignos==2.3.1
- pandoc-tablenos==2.2.2
- pandoc-xnos==2.4.3
- pybase62==0.4.3
- pysha3==1.0.2
- python-bitcoinlib==0.10.2
Expand Down
3 changes: 3 additions & 0 deletions build/pandoc/defaults/html.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
# Load on top of common defaults.
to: html5
output-file: output/manuscript.html
# include-before-body:
# - build/plugins/d3.html
include-after-body:
- build/themes/default.html
# - build/plugins/inline-svg.html
- build/plugins/anchors.html
- build/plugins/accordion.html
- build/plugins/tooltips.html
Expand Down
16 changes: 16 additions & 0 deletions build/plugins/d3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- d3 plugin -->

<script
src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.2.0/d3.min.js"
integrity="sha512-C2RveGuPIWqkaLAluvoxyiaN1XYNe5ss11urhZWZYBUA9Ydgj+hfGKPcxCzTwut1/fmjEZR7Ac35f2aycT8Ogw=="
crossorigin="anonymous"
>
// /////////////////////////
// DESCRIPTION
// /////////////////////////

// This third-party plugin 'D3' allows you to create complex, dynamic,
// interactive, data-driven visualizations in SVG.

// https://d3js.org/
</script>
62 changes: 62 additions & 0 deletions build/plugins/inline-svg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!-- inline svg plugin -->

<script>
(function() {
// /////////////////////////
// DESCRIPTION
// /////////////////////////

// This Manubot plugin fetches the text source code of SVGs in <img> tags,
// and inserts it into the document in-place. This provides many
// advantages, such as being able to style SVGs globally from the CSS
// themes, and being able to make SVGs interactive with JavaScript and D3.
// If you have a script that expects SVGs to be inlined, wait for an
// "SVGLoaded" event before running it.

// Note: This requires the page to be served from a server to work
// See: https://stackoverflow.com/a/11063963/2180570
// Tip: Use the manubot commands to open the page in a local webserver
// See: https://github.com/manubot/rootstock#local-execution

// /////////////////////////
// SCRIPT
// /////////////////////////

// start script
async function start() {
// get all <img> tags that have "src" attributes that end with ".svg"
const imgs = document.querySelectorAll('img[src$=".svg"]');
const inlineSvgs = Array.from(imgs).map(inlineSvg);
await Promise.all(inlineSvgs);

// dispatch "inline finished" event
document.dispatchEvent(new Event('SVGLoaded'));
}

// take an svg <img> tag, fetch its source code, and replace it
async function inlineSvg(img) {
try {
// fetch svg source code
const response = await fetch(img.src);
if (!response.ok) throw new Error('Couldn\'t get SVG source');
const source = await response.text();
if (!source.trim()) throw new Error('No SVG source');
// parse specifically as svg, create new (hidden) dom node
const svg = new DOMParser()
.parseFromString(source, 'image/svg+xml')
.querySelector('svg');
if (!svg) throw new Error('Couldn\'t parse SVG');
// transfer original img attributes into new svg
for (const { name, value } of img.attributes)
svg.setAttribute(name, value);
// replace original image with new svg
img.outerHTML = svg.outerHTML;
} catch (error) {
console.log(error);
}
}

// start script when document is finished loading
window.addEventListener('load', start);
})();
</script>
12 changes: 8 additions & 4 deletions build/plugins/math.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<!-- math plugin configuration -->
<!-- mathjax plugin configuration -->

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"CommonHTML": { linebreaks: { automatic: true } },
"HTML-CSS": { linebreaks: { automatic: true } },
"SVG": { linebreaks: { automatic: true } },
"fast-preview": { disabled: true }
});
});
</script>

<!-- math plugin -->
<!-- mathjax plugin -->

<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"
integrity="sha512-0doc9hKxR3PYwso42RD1p5ySZpzzuDiOwMrdCEh2WdJZCjcmFKc/wEnL+z8fBQrnHoiNWbo+3fiGkOYXBdQp4A=="
crossorigin="anonymous"
>
// /////////////////////////
// DESCRIPTION
// /////////////////////////
Expand Down
11 changes: 7 additions & 4 deletions build/themes/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,17 @@
}

/* figure image element */
figure img {
figure > img,
figure > svg {
max-width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}

/* figure auto-number */
img + figcaption > span:first-of-type {
img + figcaption > span:first-of-type,
svg + figcaption > span:first-of-type {
font-weight: bold;
margin-right: 5px;
}
Expand Down Expand Up @@ -804,7 +806,8 @@
}

/* tooltip copy of <img> */
#tooltip_content > figure > img {
#tooltip_content > figure > img,
#tooltip_content > figure > svg {
max-height: 260px;
}

Expand Down Expand Up @@ -1055,7 +1058,7 @@

@media only screen {
/* regular <img> in document when hovered */
.lightbox_document_img:hover {
img.lightbox_document_img:hover {
cursor: pointer;
}

Expand Down