Show More
@@ -80,11 +80,11 b' def markdown2latex(src):' | |||||
80 | """ |
|
80 | """ | |
81 | p = subprocess.Popen('pandoc -f markdown -t latex'.split(), |
|
81 | p = subprocess.Popen('pandoc -f markdown -t latex'.split(), | |
82 | stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
|
82 | stdin=subprocess.PIPE, stdout=subprocess.PIPE) | |
83 | out, err = p.communicate(src) |
|
83 | out, err = p.communicate(src.encode('utf-8')) | |
84 | if err: |
|
84 | if err: | |
85 | print(err, file=sys.stderr) |
|
85 | print(err, file=sys.stderr) | |
86 | #print('*'*20+'\n', out, '\n'+'*'*20) # dbg |
|
86 | #print('*'*20+'\n', out, '\n'+'*'*20) # dbg | |
87 | return out |
|
87 | return unicode(out,'utf-8') | |
88 |
|
88 | |||
89 |
|
89 | |||
90 | def rst_directive(directive, text=''): |
|
90 | def rst_directive(directive, text=''): | |
@@ -139,9 +139,9 b' class Converter(object):' | |||||
139 | if cell.cell_type in ('markdown', 'raw'): |
|
139 | if cell.cell_type in ('markdown', 'raw'): | |
140 | remove_fake_files_url(cell) |
|
140 | remove_fake_files_url(cell) | |
141 | lines.extend(conv_fn(cell)) |
|
141 | lines.extend(conv_fn(cell)) | |
142 | lines.append('') |
|
142 | lines.append(u'') | |
143 | lines.extend(self.optional_footer()) |
|
143 | lines.extend(self.optional_footer()) | |
144 | return '\n'.join(lines) |
|
144 | return u'\n'.join(lines) | |
145 |
|
145 | |||
146 | def render(self): |
|
146 | def render(self): | |
147 | "read, convert, and save self.infile" |
|
147 | "read, convert, and save self.infile" | |
@@ -481,12 +481,12 b' class ConverterLaTeX(Converter):' | |||||
481 | Name of the environment to bracket with begin/end. |
|
481 | Name of the environment to bracket with begin/end. | |
482 |
|
482 | |||
483 | lines: """ |
|
483 | lines: """ | |
484 | out = [r'\begin{%s}' % environment] |
|
484 | out = [ur'\begin{%s}' % environment] | |
485 | if isinstance(lines, basestring): |
|
485 | if isinstance(lines, basestring): | |
486 | out.append(lines) |
|
486 | out.append(lines) | |
487 | else: # list |
|
487 | else: # list | |
488 | out.extend(lines) |
|
488 | out.extend(lines) | |
489 | out.append(r'\end{%s}' % environment) |
|
489 | out.append(ur'\end{%s}' % environment) | |
490 | return out |
|
490 | return out | |
491 |
|
491 | |||
492 | def convert(self): |
|
492 | def convert(self): | |
@@ -539,7 +539,7 b' class ConverterLaTeX(Converter):' | |||||
539 | return [] |
|
539 | return [] | |
540 |
|
540 | |||
541 | # Cell codes first carry input code, we use lstlisting for that |
|
541 | # Cell codes first carry input code, we use lstlisting for that | |
542 | lines = [r'\begin{codecell}'] |
|
542 | lines = [ur'\begin{codecell}'] | |
543 |
|
543 | |||
544 | lines.extend(self.in_env('codeinput', |
|
544 | lines.extend(self.in_env('codeinput', | |
545 | self.in_env('lstlisting', cell.input))) |
|
545 | self.in_env('lstlisting', cell.input))) | |
@@ -553,7 +553,7 b' class ConverterLaTeX(Converter):' | |||||
553 | if outlines: |
|
553 | if outlines: | |
554 | lines.extend(self.in_env('codeoutput', outlines)) |
|
554 | lines.extend(self.in_env('codeoutput', outlines)) | |
555 |
|
555 | |||
556 | lines.append(r'\end{codecell}') |
|
556 | lines.append(ur'\end{codecell}') | |
557 |
|
557 | |||
558 | return lines |
|
558 | return lines | |
559 |
|
559 |
@@ -5,6 +5,8 b'' | |||||
5 | \usepackage{amsmath} |
|
5 | \usepackage{amsmath} | |
6 | \usepackage{amssymb} |
|
6 | \usepackage{amssymb} | |
7 | \usepackage{graphicx} |
|
7 | \usepackage{graphicx} | |
|
8 | \usepackage{ucs} | |||
|
9 | \usepackage[utf8x]{inputenc} | |||
8 |
|
10 | |||
9 | % needed for markdown enumerations to work |
|
11 | % needed for markdown enumerations to work | |
10 | \usepackage{enumerate} |
|
12 | \usepackage{enumerate} | |
@@ -58,9 +60,11 b'' | |||||
58 | {\endMakeFramed} |
|
60 | {\endMakeFramed} | |
59 |
|
61 | |||
60 | % Use and configure listings package for nicely formatted code |
|
62 | % Use and configure listings package for nicely formatted code | |
61 | \usepackage{listings} |
|
63 | \usepackage{listingsutf8} | |
62 | \lstset{ |
|
64 | \lstset{ | |
63 | language=python, |
|
65 | language=python, | |
|
66 | inputencoding=utf8x, | |||
|
67 | extendedchars=\true, | |||
64 | aboveskip=\smallskipamount, |
|
68 | aboveskip=\smallskipamount, | |
65 | belowskip=\smallskipamount, |
|
69 | belowskip=\smallskipamount, | |
66 | %xleftmargin=3mm, |
|
70 | %xleftmargin=3mm, |
General Comments 0
You need to be logged in to leave comments.
Login now