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
5b381a36
Kaydet (Commit)
5b381a36
authored
Tem 04, 2012
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make ANSI the default output style
üst
0712f403
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
highlight.py
Tools/scripts/highlight.py
+9
-12
No files found.
Tools/scripts/highlight.py
Dosyayı görüntüle @
5b381a36
...
...
@@ -4,7 +4,7 @@
Example command-line calls:
# Show syntax highlighted code in the terminal window
$ ./highlight.py
-a
myfile.py
$ ./highlight.py myfile.py
# Colorize myfile.py and display in a browser
$ ./highlight.py -b myfile.py
...
...
@@ -13,7 +13,7 @@ Example command-line calls:
./highlight.py -s myfile.py
# Create a complete HTML file
$ ./highlight.py myfile.py > myfile.html
$ ./highlight.py
-c
myfile.py > myfile.html
'''
...
...
@@ -149,31 +149,28 @@ if __name__ == '__main__':
description
=
'Add syntax highlighting to Python source'
)
parser
.
add_argument
(
'sourcefile'
,
metavar
=
'SOURCEFILE'
,
help
=
'File containing Python sourcecode'
)
parser
.
add_argument
(
'-a'
,
'--ansi'
,
action
=
'store_true'
,
help
=
'emit ANSI escape highlighted source'
)
parser
.
add_argument
(
'-b'
,
'--browser'
,
action
=
'store_true'
,
help
=
'launch a browser to show results'
)
parser
.
add_argument
(
'-c'
,
'--complete'
,
action
=
'store_true'
,
help
=
'build a complete html webpage'
)
parser
.
add_argument
(
'-s'
,
'--section'
,
action
=
'store_true'
,
help
=
'show an HTML section rather than a complete webpage'
)
args
=
parser
.
parse_args
()
if
args
.
browser
and
args
.
section
:
if
args
.
section
and
(
args
.
browser
or
args
.
complete
)
:
parser
.
error
(
'The -s/--section option is incompatible with '
'the -b/--browser option'
)
if
args
.
ansi
and
(
args
.
browser
or
args
.
section
):
parser
.
error
(
'The -a/--ansi option is incompatible with '
'the -b/--browser and -s/--section options'
)
'the -b/--browser or -c/--complete options'
)
sourcefile
=
args
.
sourcefile
with
open
(
sourcefile
)
as
f
:
source
=
f
.
read
()
if
args
.
ansi
:
encoded
=
colorize_ansi
(
sourc
e
)
if
args
.
complete
or
args
.
browser
:
encoded
=
build_page
(
source
,
title
=
sourcefil
e
)
elif
args
.
section
:
encoded
=
colorize_html
(
source
)
else
:
encoded
=
build_page
(
source
,
title
=
sourcefil
e
)
encoded
=
colorize_ansi
(
sourc
e
)
if
args
.
browser
:
htmlfile
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
sourcefile
))[
0
]
+
'.html'
...
...
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