Skip to content
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
6 changes: 6 additions & 0 deletions app/views/layouts/application.pdf.erbtex
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
}

\usepackage[fencedCode,hashEnumerators,pipeTables,texMathDollars]{markdown}
\markdownSetup{rendererPrototypes={
ulBeginTight={\begin{itemize}},
ulEndTight={\end{itemize}},
olBeginTight={\begin{enumerate}},
olEndTight={\end{enumerate}}
}}

\usepackage{luatextra}
\defaultfontfeatures{Ligatures=TeX}
Expand Down
14 changes: 11 additions & 3 deletions app/views/layouts/jupynotex.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ def _validator_positive_int(value):
return value


def _as_lines(value):
"""Return notebook text stored as either a string or list of strings."""
if isinstance(value, str):
return value.splitlines()
return value


def _process_plain_text(lines, config_options=None):
"""Wrap a series of lines around a verbatim indication."""
if config_options is None:
config_options = {}

result = []
result.extend(VERBATIM_BEGIN)
lines = _as_lines(lines)
for line in lines:
line = line.strip()

Expand Down Expand Up @@ -169,8 +177,8 @@ def __init__(self, path, config_options):
with open(path, 'rt', encoding='utf8') as fh:
nb_data = json.load(fh)

# get the languaje, to highlight
lang = nb_data['metadata']['language_info']['name']
# get the language, when available, to highlight
lang = nb_data.get('metadata', {}).get('language_info', {}).get('name')
self._highlight_delimiters = HIGHLIGHTERS.get(lang, HIGHLIGHTERS[None])

# get all cells
Expand All @@ -186,7 +194,7 @@ def _validate_config(self, config):

def _proc_src(self, content):
"""Process the source of a cell."""
source = content['source']
source = _as_lines(content['source'])
result = []
if content['cell_type'] == 'code':
begin, end = self._highlight_delimiters
Expand Down
Loading