Skip to content

Instantly share code, notes, and snippets.

@karenc
Last active March 13, 2019 21:26
Show Gist options
  • Save karenc/419dc0866481d4a40f4409b023b28169 to your computer and use it in GitHub Desktop.
Save karenc/419dc0866481d4a40f4409b023b28169 to your computer and use it in GitHub Desktop.

The following are commands in neb in PRs right now. This is not how the textbook developers will create a pdf. The textbook developers will use scripts in cnx-recipes as they have been doing before. We will change the scripts to use neb under the hood.


  1. Download the "Introduction to Business" book from production using neb get:

    neb get prod col25734 1.8.5         
    
  2. Run neb assemble to create a single html with all the modules and TOC. The CLI part is not yet ready so running the python code to get the result:

    karen@yachiyo:~/src/nebuchadnezzar$ python
    Python 3.6.7 (default, Oct 22 2018, 11:32:17)
    [GCC 8.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from nebu.models.binder import Binder
    >>> from pathlib import Path
    >>> b = Binder.from_collection_xml(Path('col25734_1.8.5/collection.xml'))
    >>> b
    <nebu.models.binder.Binder object at 0x7f7ff7111ac8>
    >>> from cnxepub.formatters import SingleHTMLFormatter
    >>> open('col25734_1.8.5/collection.assembled.xhtml', 'w').write(str(SingleHTMLFormatter(b)))
    3081300
    >>>
    
  3. Run neb mathify to transform the math into svg.

    karen@yachiyo:~/src/nebuchadnezzar$ neb mathify col25734_1.8.5/
    Math converted to svg in col25734_1.8.5/collection.mathified.xhtml
    

    To check that math is indeed converted to svg, you can open col25734_1.8.5/collection.mathified.xhtml in your browser and search for "The Accounting Equations". "Assets - Liabilities = Owners' equity" should be an svg.

  4. Run neb bake to bake the book with a recipe and add style to the html. You need to have cnx-recipes checked out locally to use the recipes and styles:

    karen@yachiyo:~/src/nebuchadnezzar$ neb bake -r ../cnx-recipes/recipes/output/intro-business.css -s ../cnx-recipes/styles/output/intro-business.css col25734_1.8.5/
    Baked HTML in col25734_1.8.5/collection.baked.xhtml
    
  5. Run neb pdf to create a pdf: (You need to pass in the styles again for now)

    karen@yachiyo:~/src/nebuchadnezzar$ neb pdf -s ../cnx-recipes/styles/output/intro-business.css col25734_1.8.5/
    PDF generated col25734_1.8.5/collection.pdf
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment