Show More
@@ -122,12 +122,13 b' def single_ansi2latex(code):' | |||||
122 | color_code = style_code.split(';')[1] |
|
122 | color_code = style_code.split(';')[1] | |
123 | is_normal = style_code.split(';')[0] == '0' |
|
123 | is_normal = style_code.split(';')[0] == '0' | |
124 |
|
124 | |||
125 |
# regular |
|
125 | # regular weight | |
126 | if (code == style_code) or (is_normal and code == color_code): |
|
126 | if (code == style_code) or (is_normal and code == color_code): | |
127 | return '\\'+color[0].lower()+'{', 1 |
|
127 | ||
128 | # bold fonts |
|
128 | return r'{\color{'+color[0].lower()+'}', 1 | |
|
129 | # bold | |||
129 | if code == style_code[:3]+str(1)+style_code[3:]: |
|
130 | if code == style_code[:3]+str(1)+style_code[3:]: | |
130 |
return '\ |
|
131 | return r'\textbf{\color{'+color[0].lower()+'}', 1 | |
131 | return '', 0 |
|
132 | return '', 0 | |
132 |
|
133 | |||
133 | def ansi2latex(text): |
|
134 | def ansi2latex(text): | |
@@ -149,8 +150,8 b' def ansi2latex(text):' | |||||
149 | texform, openbrack = single_ansi2latex(match.group()) |
|
150 | texform, openbrack = single_ansi2latex(match.group()) | |
150 | outstring += texform |
|
151 | outstring += texform | |
151 | last_end = match.end() |
|
152 | last_end = match.end() | |
152 |
|
153 | |||
153 | #Add the remainer of the string and THEN close any remaining color brackets. |
|
154 | # Add the remainer of the string and THEN close any remaining color brackets. | |
154 | outstring += text[last_end:] |
|
155 | outstring += text[last_end:] | |
155 | if openbrack: |
|
156 | if openbrack: | |
156 | outstring += '}'*openbrack |
|
157 | outstring += '}'*openbrack |
@@ -68,12 +68,12 b' class TestAnsi(TestsBase):' | |||||
68 | def test_ansi2latex(self): |
|
68 | def test_ansi2latex(self): | |
69 | """ansi2latex test""" |
|
69 | """ansi2latex test""" | |
70 | correct_outputs = { |
|
70 | correct_outputs = { | |
71 |
'%s' % (TermColors.Red) : r'\ |
|
71 | '%s' % (TermColors.Red) : r'{\color{red}}', | |
72 |
'hello%s' % TermColors.Blue: r'hello\ |
|
72 | 'hello%s' % TermColors.Blue: r'hello{\color{blue}}', | |
73 |
'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : r'he\green{ |
|
73 | 'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : r'he{\color{green}}{\color{cyan}llo}', | |
74 |
'%shello' % TermColors.Yellow : r'\yellow |
|
74 | '%shello' % TermColors.Yellow : r'{\color{yellow}hello}', | |
75 |
'{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : r'\ |
|
75 | '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : r'{\color{white}h}{\color{white}e}{\color{white}l}{\color{white}l}{\color{white}o}{\color{white}}', | |
76 |
'hel%slo' % TermColors.Green : r'hel\ |
|
76 | 'hel%slo' % TermColors.Green : r'hel{\color{green}lo}', | |
77 | 'hello' : 'hello'} |
|
77 | 'hello' : 'hello'} | |
78 |
|
78 | |||
79 | for inval, outval in correct_outputs.items(): |
|
79 | for inval, outval in correct_outputs.items(): |
@@ -43,15 +43,45 b' This template does not define a docclass, the inheriting class must define this.' | |||||
43 | \definecolor{inputbackground}{rgb}{.95, .95, .85} |
|
43 | \definecolor{inputbackground}{rgb}{.95, .95, .85} | |
44 | \definecolor{outputbackground}{rgb}{.95, .95, .95} |
|
44 | \definecolor{outputbackground}{rgb}{.95, .95, .95} | |
45 | \definecolor{traceback}{rgb}{1, .95, .95} |
|
45 | \definecolor{traceback}{rgb}{1, .95, .95} | |
46 |
% |
|
46 | % ansi colors | |
47 |
\definecolor{ |
|
47 | \definecolor{red}{rgb}{.6,0,0} | |
48 |
\definecolor{ |
|
48 | \definecolor{green}{rgb}{0,.65,0} | |
|
49 | \definecolor{brown}{rgb}{0.6,0.6,0} | |||
|
50 | \definecolor{blue}{rgb}{0,.145,.698} | |||
|
51 | \definecolor{purple}{rgb}{.698,.145,.698} | |||
|
52 | \definecolor{cyan}{rgb}{0,.698,.698} | |||
|
53 | \definecolor{lightgray}{gray}{0.5} | |||
|
54 | ||||
|
55 | % bright ansi colors | |||
49 | \definecolor{darkgray}{gray}{0.25} |
|
56 | \definecolor{darkgray}{gray}{0.25} | |
50 | \definecolor{lightred}{rgb}{1.0,0.39,0.28} |
|
57 | \definecolor{lightred}{rgb}{1.0,0.39,0.28} | |
51 | \definecolor{lightgreen}{rgb}{0.48,0.99,0.0} |
|
58 | \definecolor{lightgreen}{rgb}{0.48,0.99,0.0} | |
52 | \definecolor{lightblue}{rgb}{0.53,0.81,0.92} |
|
59 | \definecolor{lightblue}{rgb}{0.53,0.81,0.92} | |
53 | \definecolor{lightpurple}{rgb}{0.87,0.63,0.87} |
|
60 | \definecolor{lightpurple}{rgb}{0.87,0.63,0.87} | |
54 | \definecolor{lightcyan}{rgb}{0.5,1.0,0.83} |
|
61 | \definecolor{lightcyan}{rgb}{0.5,1.0,0.83} | |
|
62 | ||||
|
63 | % commands and environments needed by pandoc snippets | |||
|
64 | % extracted from the output of `pandoc -s` | |||
|
65 | ||||
|
66 | \DefineShortVerb[commandchars=\\\{\}]{\|} | |||
|
67 | \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} | |||
|
68 | % Add ',fontsize=\small' for more characters per line | |||
|
69 | \newenvironment{Shaded}{}{} | |||
|
70 | \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | |||
|
71 | \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} | |||
|
72 | \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |||
|
73 | \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |||
|
74 | \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |||
|
75 | \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |||
|
76 | \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |||
|
77 | \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} | |||
|
78 | \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} | |||
|
79 | \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |||
|
80 | \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} | |||
|
81 | \newcommand{\RegionMarkerTok}[1]{{#1}} | |||
|
82 | \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |||
|
83 | \newcommand{\NormalTok}[1]{{#1}} | |||
|
84 | ||||
55 | % Define a nice break command that doesn't care if a line doesn't already |
|
85 | % Define a nice break command that doesn't care if a line doesn't already | |
56 | % exist. |
|
86 | % exist. | |
57 | \def\br{\hspace*{\fill} \\* } |
|
87 | \def\br{\hspace*{\fill} \\* } |
@@ -1,6 +1,6 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
3 |
"name": " |
|
3 | "name": "" | |
4 | }, |
|
4 | }, | |
5 | "nbformat": 3, |
|
5 | "nbformat": 3, | |
6 | "nbformat_minor": 0, |
|
6 | "nbformat_minor": 0, | |
@@ -171,12 +171,15 b'' | |||||
171 | "prompt_number": 14 |
|
171 | "prompt_number": 14 | |
172 | }, |
|
172 | }, | |
173 | { |
|
173 | { | |
174 |
"cell_type": " |
|
174 | "cell_type": "markdown", | |
175 | "collapsed": false, |
|
|||
176 | "input": [], |
|
|||
177 | "language": "python", |
|
|||
178 | "metadata": {}, |
|
175 | "metadata": {}, | |
179 |
" |
|
176 | "source": [ | |
|
177 | "```python\n", | |||
|
178 | "def foo(bar=1):\n", | |||
|
179 | " \"\"\"docstring\"\"\"\n", | |||
|
180 | " raise Exception(\"message\")\n", | |||
|
181 | "```" | |||
|
182 | ] | |||
180 | } |
|
183 | } | |
181 | ], |
|
184 | ], | |
182 | "metadata": {} |
|
185 | "metadata": {} |
@@ -1296,28 +1296,29 b'' | |||||
1296 | "collapsed": false, |
|
1296 | "collapsed": false, | |
1297 | "input": [ |
|
1297 | "input": [ | |
1298 | "%%latex\n", |
|
1298 | "%%latex\n", | |
1299 |
"\\begin{align |
|
1299 | "\\begin{align}\n", | |
1300 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n", |
|
1300 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n", | |
1301 | "\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", |
|
1301 | "\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", | |
1302 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", |
|
1302 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", | |
1303 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n", |
|
1303 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n", | |
1304 |
"\\end{align |
|
1304 | "\\end{align}" | |
1305 | ], |
|
1305 | ], | |
1306 | "language": "python", |
|
1306 | "language": "python", | |
1307 | "metadata": {}, |
|
1307 | "metadata": {}, | |
1308 | "outputs": [ |
|
1308 | "outputs": [ | |
1309 | { |
|
1309 | { | |
1310 | "latex": [ |
|
1310 | "latex": [ | |
1311 |
"\\begin{align |
|
1311 | "\\begin{align}\n", | |
1312 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n", |
|
1312 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\\n", | |
1313 | "\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", |
|
1313 | "\\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", | |
1314 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", |
|
1314 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", | |
1315 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n", |
|
1315 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0\n", | |
1316 |
"\\end{align |
|
1316 | "\\end{align}" | |
1317 | ], |
|
1317 | ], | |
|
1318 | "metadata": {}, | |||
1318 | "output_type": "display_data", |
|
1319 | "output_type": "display_data", | |
1319 | "text": [ |
|
1320 | "text": [ | |
1320 |
"<IPython.core.display.Latex at 0x10 |
|
1321 | "<IPython.core.display.Latex at 0x106c04dd0>" | |
1321 | ] |
|
1322 | ] | |
1322 | } |
|
1323 | } | |
1323 | ], |
|
1324 | ], |
@@ -1,6 +1,6 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
3 | "name": "Typesetting Math Using MathJax" |
|
3 | "name": "" | |
4 | }, |
|
4 | }, | |
5 | "nbformat": 3, |
|
5 | "nbformat": 3, | |
6 | "nbformat_minor": 0, |
|
6 | "nbformat_minor": 0, | |
@@ -24,18 +24,18 b'' | |||||
24 | "\n", |
|
24 | "\n", | |
25 | "## The Lorenz Equations\n", |
|
25 | "## The Lorenz Equations\n", | |
26 | "### Source\n", |
|
26 | "### Source\n", | |
27 |
"```\\begin{align |
|
27 | "```\\begin{align}\n", | |
28 | "\\dot{x} & = \\sigma(y-x) \\\\\n", |
|
28 | "\\dot{x} & = \\sigma(y-x) \\\\\n", | |
29 | "\\dot{y} & = \\rho x - y - xz \\\\\n", |
|
29 | "\\dot{y} & = \\rho x - y - xz \\\\\n", | |
30 | "\\dot{z} & = -\\beta z + xy\n", |
|
30 | "\\dot{z} & = -\\beta z + xy\n", | |
31 |
"\\end{align |
|
31 | "\\end{align}\n", | |
32 | "```\n", |
|
32 | "```\n", | |
33 | "### Display\n", |
|
33 | "### Display\n", | |
34 |
"\\begin{align |
|
34 | "\\begin{align}\n", | |
35 | "\\dot{x} & = \\sigma(y-x) \\\\\n", |
|
35 | "\\dot{x} & = \\sigma(y-x) \\\\\n", | |
36 | "\\dot{y} & = \\rho x - y - xz \\\\\n", |
|
36 | "\\dot{y} & = \\rho x - y - xz \\\\\n", | |
37 | "\\dot{z} & = -\\beta z + xy\n", |
|
37 | "\\dot{z} & = -\\beta z + xy\n", | |
38 |
"\\end{align |
|
38 | "\\end{align}" | |
39 | ] |
|
39 | ] | |
40 | }, |
|
40 | }, | |
41 | { |
|
41 | { | |
@@ -140,18 +140,18 b'' | |||||
140 | "source": [ |
|
140 | "source": [ | |
141 | "## Maxwell's Equations\n", |
|
141 | "## Maxwell's Equations\n", | |
142 | "### Source\n", |
|
142 | "### Source\n", | |
143 |
"```\\begin{align |
|
143 | "```\\begin{align}\n", | |
144 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", |
|
144 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", | |
145 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", |
|
145 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", | |
146 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n", |
|
146 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n", | |
147 |
"\\end{align |
|
147 | "\\end{align}\n", | |
148 | "```\n", |
|
148 | "```\n", | |
149 | "### Display\n", |
|
149 | "### Display\n", | |
150 |
"\\begin{align |
|
150 | "\\begin{align}\n", | |
151 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", |
|
151 | "\\nabla \\times \\vec{\\mathbf{B}} -\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{E}}}{\\partial t} & = \\frac{4\\pi}{c}\\vec{\\mathbf{j}} \\\\ \\nabla \\cdot \\vec{\\mathbf{E}} & = 4 \\pi \\rho \\\\\n", | |
152 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", |
|
152 | "\\nabla \\times \\vec{\\mathbf{E}}\\, +\\, \\frac1c\\, \\frac{\\partial\\vec{\\mathbf{B}}}{\\partial t} & = \\vec{\\mathbf{0}} \\\\\n", | |
153 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n", |
|
153 | "\\nabla \\cdot \\vec{\\mathbf{B}} & = 0 \n", | |
154 |
"\\end{align |
|
154 | "\\end{align}" | |
155 | ] |
|
155 | ] | |
156 | }, |
|
156 | }, | |
157 | { |
|
157 | { |
General Comments 0
You need to be logged in to leave comments.
Login now