{ "info": { "author": "Hans Moritz Gunther", "author_email": "moritz.guenther@gmx.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Topic :: Text Processing :: Markup :: LaTeX", "Topic :: Utilities" ], "description": "ipythontools\n============\nThis module installs two command line scripts:\n\n- ``jupyter2article`` extracts some content (raw cells, markdown cells, code output) from a\n Jupyter/IPython notebook and pastes it into a new file. It also converst markdown headings\n to proper LaTeX chapter, section, subsetion etc. and inserts appropriate labels.\n This converter is not intended to replace the nbconvert from the IPython\n project. Instead, it serves one very specific purpose:\n Turn a notebook into a LaTeX file that I can submit to the journal.\n\n- ``jupyterspellcheck`` spell checks markdown and raw cells in a notebook.\n\nNote that scipts and procedures have been renamed to \"jupyter\", but the name of the package\nand its directory structure still reflect that fact that Jupyter notebooks started out as part of the `IPython `_ project.\n\n\nThe converter\n-------------\nWhen I first encountered the IPython notebook, I thought this was a solution\nlooking for a problem. However, I have since been converted!\nThe tipping point for me was this: I want to version control my papers and\nI always had multiple directories for analysis code, plotting code, LaTeX files,\nplot scripts and figures and tables. That's just so unwieldy.\nAlso, I found it cumbersome to email figures to individual collaborators all\nthe time.\nThe Notebook can hold all this information in one place and I can just provide\nmy co-authors with a link to the github repository once and they have access\nto the latest version all the time. Even if they do not use python, they can\nstill see the all the current figures using nbviewer.ipython.org\n\nNow all papers I work on a are written in an IPython notebook. So, the final\nstep to do is to convert the notebook to the LaTeX file I can submit to a\njournal. That's what this simple converter code does.\n\nThis converter is not intended to replace the nbconvert from the IPython\nproject. Instead, it serves one very specific purpose:\nTurn a notebook into a LaTeX file that I can submit to the journal.\n\n**How to use it**\n\n*As a script*\n\nInstalling this module places a script in your path, so you can do:\n\n jupyter2article myanalysis.ipynb myanalysis.tex\n\nIn this case it's run with my set of design choices (see below).\n\n*As a Python module*\n\nImport into python and make a ``NotebookConverter`` object:\n\n from ipynb2article import NotebookConverter\n converter = NotebookConverter\n\nThen, customize how each type of cell is converted by changing the converter:\n\n converter.cellconverters['code'] = NotebookConverter.IgnoreConverter()\n\nFinally, call:\n\n converter.convert(infile, outfile, ...)\n\nThis method allows you to use only part of a notebook file (ignore to first n\ncells or ignore everything until a cell has a specific string value, e.g.\n\"The paper starts here\"). Also, it allows you to provide a text file that will be\npasted before or after the converted notebook (you can put the '\\usepackage' and\nsimilar stuff in those files so they don't clutter your notebook).\nHowever, I do not use this option any longer, because that means I would have\nmultiple input files. If I put all those LaTeX headers into the notebook as\nwell, I only have a single file.\n\n**Design**\n\nThe code is written around these design ideas:\n\n- Be able to ignore certain parts of the notebook (e.g. introductory comments\n in the first few cells).\n- Convert headings to section / subsection etc.\n I generally level 2 such as \"## Heading\" for section, \"### Heading\" for subsections etc.\n- Copy text in \"markdown\" and \"raw text\" cells. To simplify, I just write\n real LaTeX code in those cells. All equations will be rendered correctly\n in the notebook file for me and my co-authors to see.\n When I want to highlight something I type LaTeX \"\\emph{}\" or \"\\textbf{}\",\n not the markdown equivalents. That looks not as nice in the notebook, but\n makes live so much easier.\n Also, markdown does not recognize \"\\cite\", \"\\ref\" and \"\\label\". Again, it\n looks not as nice in markdown, but\n (1) I only need to know LaTeX and (2) it works flawlessly when converted.\n- No figure conversion. Instead, in the notebook itself I issue:\n\n > fig.savefig('/path/to/my/article/XXX.eps')\n\n because ApJ requires me to submit figures as separate files anyway.\n- Just type figure captions into markdown cells.\n- No conversion of code cells. Who wants code in an ApJ paper?\n- Occasionally, I want to have the output of a computation (e.g. a table\n written with astropy in LaTeX format) in the article. Keep it simple.\n Output of all code cells that have a certain comment string (I use\n \"# output->LaTeX\") is copied verbatim to the LaTeX file.\n- Work with the python standard library only. No external dependencies.\n\n\nTo implement this I wrote a converter for each cell type.\n``LiteralSourceConverter`` just takes the literal string value (it also adds\na line break at the end of the cell) and puts it into the LaTeX file\n(use for markdown and raw text cells),\n``MarkedCodeOutputConverter`` checks if a code cell has a specific string in\nit and if so, it copies the output of this cell, and ``LatexHeadingConverter``\nlooks for the level of the heading and turns that into LaTeX (it also adds\nas label like \"\\label{sect:title}\").\n\n\nThe spellchecker\n----------------\nSpell check the markdown text in IPython notebooks\n\nAs much as I love the IPython notebook, there is one big drawback (at least in\nmy installation). When I type into a cell in the browser (I use firefox) there\nis no automatic spell checking of the input. Sure, the notebook has syntax\nhighlighting for code cells in python, but I want to do my entire paper\nwriting in the notebook and for me that means that a spell checker for cells\nwith markdown, headings or raw text is absolutely essential.\nOn the other hand, I cannot just run e.g. ``ispell`` on the ipynb file, since\nmost of its contents is actually code and not plain English.\nSo, I wanted to write a spell checker, that parses the ipynb file and spell checks\nonly the markdown, heading and raw text input cells.\n\nOh, one more thing: Because I type a lot of raw LaTeX in my notebooks (see my\nother post on ``ipynb2article.py``) as opposed to real markdown that resembles\nEnglish much better I define a custom filter function that\nmakes sure that strings which look like LaTeX commands will not be spell checked\n(since very few LaTeX command are valid English words so that would give a lot of\napparent typos).\nMore complicated filters that avoid spell checking within equations or\ncommands like ``\\label{XXX}`` or ``\\cite{}`` are possible (they would be called\na ``chunker`` in ``pyenchant``). Check the `github repository `_\nfor this code if you want to see if I have an improved version.\n\n\n*How to use this script*:\n\nClose down the notebook you want to spell check in IPython, then simply type on\nthe command line:\n\n jupyterspellcheck filein.ipynb fileout.ipynb\n\nOpen the new file in IPython, run all cells again and keep working.\n\n`filein` and `fileout` can be the same filename (in this case the old file will get\noverwritten with the spelling corrected version), but I recommend to keep a copy\njust in case something gets screwed up.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hamogu/ipythontools", "keywords": "ipython latex notebok jupyter", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "ipythontools", "package_url": "https://pypi.org/project/ipythontools/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ipythontools/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/hamogu/ipythontools" }, "release_url": "https://pypi.org/project/ipythontools/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Jupyter/IPython notebook to latex converter and spell checker", "version": "0.1.0" }, "last_serial": 1725964, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e30e81afde3912cdc0153ebc79524c7c", "sha256": "31cade3f9aebb53899eb4d45f46f8dca5b4aaa04477f63040c38e48fd18c7303" }, "downloads": -1, "filename": "ipythontools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e30e81afde3912cdc0153ebc79524c7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8619, "upload_time": "2015-09-17T01:29:34", "url": "https://files.pythonhosted.org/packages/7f/ac/624e70361ea967fe1937559b7e09e9590dc6eea2bb1b920feaf14421449a/ipythontools-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e30e81afde3912cdc0153ebc79524c7c", "sha256": "31cade3f9aebb53899eb4d45f46f8dca5b4aaa04477f63040c38e48fd18c7303" }, "downloads": -1, "filename": "ipythontools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e30e81afde3912cdc0153ebc79524c7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8619, "upload_time": "2015-09-17T01:29:34", "url": "https://files.pythonhosted.org/packages/7f/ac/624e70361ea967fe1937559b7e09e9590dc6eea2bb1b920feaf14421449a/ipythontools-0.1.0.tar.gz" } ] }