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

asciidoctor-jupyter

v0.7.0

Published

A Jupyter converter for Asciidoctor.js. Write your Notebook in AsciiDoc!

Downloads

238

Readme

Asciidoctor Jupyter Converter

A Jupyter converter for Asciidoctor.js. Write your Notebook in AsciiDoc!

Build JavaScript npm version

Install

$ npm i asciidoctor-jupyter

Usage

In order to use this converter, you will need to install Asciidoctor.js. Verify that the asciidoctor command is now available on your PATH by running:

$ asciidoctor -v

From the CLI (Command Line Interface)

To convert an AsciiDoc file to a Jupyter Notebook, open a terminal and type:

$ asciidoctor -r asciidoctor-jupyter -b jupyter notebook.adoc

The above command will generate a file named notebook.ipynb.

From the API

const asciidoctor = require('@asciidoctor/core')()
const JupyterConverter = require('asciidoctor-jupyter')

// register the converter
asciidoctor.ConverterFactory.register(JupyterConverter, ['jupyter'])

// convert an AsciiDoc file
asciidoctor.convertFile('notebook.adoc', { backend: 'jupyter' })

Write your Notebook

Here's a basic example of notebook written in AsciiDoc:

= The Lorenz Differential Equations
:jupyter-language-name: python
:jupyter-language-version: 3.7.8
:url-ipywidgets: https://ipywidgets.readthedocs.io/en/stable/

Before we start, we import some preliminary libraries.
We will also import (below) the accompanying `lorenz.py` file,
which contains the actual solver and plotting routine.

[source,python]
----
%matplotlib inline
from ipywidgets import interactive, fixed
----

We explore the Lorenz system of differential equations:

[latexmath]
++++
\begin{aligned}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{aligned}
++++

Let's change (stem:[\sigma], stem:[\beta], stem:[\rho]) with {url-ipywidgets}[ipywidgets] and examine the trajectories.

[source,python]
----
from lorenz import solve_lorenz
w=interactive(solve_lorenz,sigma=(0.0,60.0),rho=(0.0,50.0))
w
----

For the default set of parameters, we see the trajectories swirling around two points, called attractors.

The object returned by `interactive` is a `Widget` object and it has attributes that contain the current result and arguments:

[source,python]
----
t, x_t = w.result
----

[source,python]
----
w.kwargs
----

And here's the result:

Document attributes

| Name | Default Value | Mapping | |----------------------------|---------------|----------------------------------| | jupyter-language-name | python | metadata.language_info.name | | jupyter-language-version | 3.9.1 | metadata.language_info.version | | jupyter-kernel-name | python3 | metadata.kernelspec.name | | jupyter-kernel-language | python | metadata.kernelspec.language |

IMPORTANT: The language name defined in jupyter-language-name will be used to decide which AsciiDoc source blocks will be converted to Notebook code cells and which will be converted to Markdown cells. For instance, if the Jupyter language name is python the converter will convert source blocks that have the language python to code cells. Source blocks with other languages will be converted as Markdown cells.

Notebook file format

This converter generates [Jupyter notebooks] using Notebook file format version 4.4.