fastai / fastdoc

Create publication-quality books from Jupyter notebooks
https://fastai.github.io/fastdoc/
Apache License 2.0
231 stars 30 forks source link

Problem with chapter and section headings #10

Closed AllenDowney closed 3 years ago

AllenDowney commented 3 years ago

I'm having an odd problem with chapter and section headings. It's odd because it was previously working; I don't think I changed anything, and now it's not working.

Here's the minimum test case that replicates the problem. I have a notebook that looks like this:

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter Title\n",
    "\n",
    "Some text"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Section Title\n",
    "\n",
    "More text\n"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

And then I run fastdoc like this

fastdoc_convert_all --path . --dest_path convert_book

And here's the output

== Chapter Title

Some text

== Section Title

More text

I was expecting the first one to be a chapter heading and the second to be a section heading.

And then I'm extra confused because when I build this on Atlas I get two chapters instead of two sections.

Any idea what's happening?

jph00 commented 3 years ago

Solution is to downgrade pandoc to 2.3.1.

jph00 commented 3 years ago

Here's the issue in the nbconvert repo: https://github.com/jupyter/nbconvert/issues/1456

lewtun commented 3 years ago

For those using Ubuntu, the following steps worked for me:

# download pandoc v2.3.1 from their github releases
wget https://github.com/jgm/pandoc/releases/download/2.3.1/pandoc-2.3.1-1-amd64.deb
# install pandoc
sudo dpkg -i pandoc-2.3.1-1-amd64.deb

For those using macOS, there is a well written blog here, although I could not make it work with Big Sur 😢. Instead, the solution was to do a manual install without brew as follows:

wget https://github.com/jgm/pandoc/releases/download/2.3.1/pandoc-2.3.1-macOS.pkg
sudo installer -pkg pandoc-2.3.1-macOS.pkg -target /

One final gotcha: if you're using conda you'll find a recent version of pandoc comes installed. To remove it I ran

conda remove --force pandoc -y

and then installed v2.3.1 of pandoc using one of the approaches above.

jph00 commented 3 years ago

Or this should work on every platform, as long as you have conda installed:

conda install 'pandoc<2.3'
lewtun commented 3 years ago

Or conda install pandoc=3.2.1 should work on every platform, as long as you have conda installed.

There's a typo in the version number here, possibly because I had it permuted in the previous comment - sorry!

For some reason conda install pandoc=2.3.1 does not work for me if I do the following

$ conda create --name foo python=3.8 -y && conda activate foo
$ conda install pandoc=2.3.1
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - pandoc=2.3.1

Current channels:

  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Doing a search for the available versions gives

$ conda search pandoc
Loading channels: done
# Name                       Version           Build  Channel
pandoc                      1.19.2.1      ha5e8f32_1  pkgs/main
pandoc                         2.2.1      h1a437c5_0  pkgs/main
pandoc                       2.2.3.2               0  pkgs/main
pandoc                       2.9.2.1               0  pkgs/main
pandoc                          2.10               0  pkgs/main
pandoc                        2.10.1               0  pkgs/main
pandoc                          2.11      h0dc7051_0  pkgs/main

so presumably the appropriate choice is conda install pandoc=2.2.3.2.

Environment information

conda info

active environment : foo
    active env location : /Users/lewtun/miniconda3/envs/foo
            shell level : 1
       user config file : /Users/lewtun/.condarc
 populated config files : /Users/lewtun/.condarc
          conda version : 4.9.2
    conda-build version : not installed
         python version : 3.7.6.final.0
       virtual packages : __osx=10.16=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /Users/lewtun/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/lewtun/miniconda3/pkgs
                          /Users/lewtun/.conda/pkgs
       envs directories : /Users/lewtun/miniconda3/envs
                          /Users/lewtun/.conda/envs
               platform : osx-64
             user-agent : conda/4.9.2 requests/2.25.1 CPython/3.7.6 Darwin/20.2.0 OSX/10.16
                UID:GID : 501:20
             netrc file : None
           offline mode : False

conda config --show-sources

==> /Users/lewtun/.condarc <==
auto_activate_base: False
ssl_verify: True
channels:
  - defaults