Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c4ac789b
Kaydet (Commit)
c4ac789b
authored
Tem 15, 2012
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix-up latex styling
üst
ad5ae045
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
highlight.py
Tools/scripts/highlight.py
+15
-12
No files found.
Tools/scripts/highlight.py
Dosyayı görüntüle @
c4ac789b
...
@@ -145,23 +145,25 @@ def build_html_page(classified_text, title='python',
...
@@ -145,23 +145,25 @@ def build_html_page(classified_text, title='python',
#### LaTeX Output ##########################################
#### LaTeX Output ##########################################
default_latex_co
lor
s
=
{
default_latex_co
mmand
s
=
{
'comment'
:
'
red
'
,
'comment'
:
'
{
\
color{red}#1}
'
,
'string'
:
'
green
'
,
'string'
:
'
{
\
color{ForestGreen}#1}
'
,
'docstring'
:
'
green
'
,
'docstring'
:
'
{
\
emph{
\
color{ForestGreen}#1}}
'
,
'keyword'
:
'
orange
'
,
'keyword'
:
'
{
\
color{orange}#1}
'
,
'builtin'
:
'
purple
'
,
'builtin'
:
'
{
\
color{purple}#1}
'
,
'definition'
:
'
orange
'
,
'definition'
:
'
{
\
color{orange}#1}
'
,
'defname'
:
'
blue
'
,
'defname'
:
'
{
\
color{blue}#1}
'
,
'operator'
:
'
brown
'
,
'operator'
:
'
{
\
color{brown}#1}
'
,
}
}
default_latex_document
=
r'''
default_latex_document
=
r'''
\documentclass{article}
\documentclass{article}
\usepackage{alltt}
\usepackage{alltt}
\usepackage{upquote}
\usepackage{color}
\usepackage{color}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[cm]{fullpage}
\usepackage[cm]{fullpage}
%(macros)
s
\begin{document}
\begin{document}
\center{\LARGE{
%(title)
s}}
\center{\LARGE{
%(title)
s}}
\begin{alltt}
\begin{alltt}
...
@@ -181,17 +183,18 @@ def latex_escape(s):
...
@@ -181,17 +183,18 @@ def latex_escape(s):
return
re
.
sub
(
r'[\\#$
%
^&_{}~]'
,
lambda
mo
:
xlat
[
mo
.
group
()],
s
)
return
re
.
sub
(
r'[\\#$
%
^&_{}~]'
,
lambda
mo
:
xlat
[
mo
.
group
()],
s
)
def
latex_highlight
(
classified_text
,
title
=
'python'
,
def
latex_highlight
(
classified_text
,
title
=
'python'
,
co
lors
=
default_latex_color
s
,
co
mmands
=
default_latex_command
s
,
document
=
default_latex_document
):
document
=
default_latex_document
):
'Create a complete LaTeX document with colorized source code'
'Create a complete LaTeX document with colorized source code'
macros
=
'
\n
'
.
join
(
r'\newcommand{\py
%
s}[1]{
%
s}'
%
c
for
c
in
commands
.
items
())
result
=
[]
result
=
[]
for
kind
,
text
in
classified_text
:
for
kind
,
text
in
classified_text
:
if
kind
:
if
kind
:
result
.
append
(
r'
{\color{
%
s}'
%
colors
[
kind
]
)
result
.
append
(
r'
\py
%
s{'
%
kind
)
result
.
append
(
latex_escape
(
text
))
result
.
append
(
latex_escape
(
text
))
if
kind
:
if
kind
:
result
.
append
(
'}'
)
result
.
append
(
'}'
)
return
default_latex_document
%
dict
(
title
=
title
,
body
=
''
.
join
(
result
))
return
default_latex_document
%
dict
(
title
=
title
,
macros
=
macros
,
body
=
''
.
join
(
result
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment