summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.c (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.c)0
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.delphi (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.delphi)0
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.hs (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.hs)0
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.java (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.java)0
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.pas (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.pas)0
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.pdf (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.pdf)bin592365 -> 585220 bytes
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.py (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.py)0
-rw-r--r--Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.tex (renamed from Master/texmf-dist/doc/latex/pygmentex/demo.tex)21
-rwxr-xr-xMaster/texmf-dist/scripts/pygmentex/pygmentex.py83
-rw-r--r--Master/texmf-dist/tex/latex/pygmentex/pygmentex.sty12
10 files changed, 59 insertions, 57 deletions
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.c b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.c
index 1d739f5edf3..1d739f5edf3 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.c
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.c
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.delphi b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.delphi
index 71e38129746..71e38129746 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.delphi
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.delphi
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.hs b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.hs
index b784c890a5c..b784c890a5c 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.hs
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.hs
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.java b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.java
index bda5bb322f6..bda5bb322f6 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.java
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.java
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.pas b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.pas
index 5d63cc6e2d2..5d63cc6e2d2 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.pas
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.pas
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.pdf b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.pdf
index ccebf5004ad..a444bffd44d 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.pdf
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.py b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.py
index a5fa60eed43..a5fa60eed43 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.py
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.py
diff --git a/Master/texmf-dist/doc/latex/pygmentex/demo.tex b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.tex
index 03fe3ac0a1b..5a07f49bedf 100644
--- a/Master/texmf-dist/doc/latex/pygmentex/demo.tex
+++ b/Master/texmf-dist/doc/latex/pygmentex/pygmentex_demo.tex
@@ -8,7 +8,7 @@
\usepackage{hyperref}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tcolorbox}
-\usepackage{fvrb-ex}
+\usepackage{fancyvrb-ex}
\usepackage{tikz}
\usepackage{calc}
\usepackage{pygmentex}
@@ -85,6 +85,15 @@ $ pygmentize -L lexers
\section{First examples}
+A simple verbatim text is the first example.
+
+\begin{Example}
+\begin{pygmented}[]
+Hello world!
+ This is a simple demonstration text.
+\end{pygmented}
+\end{Example}
+
The followig C program reads two integers and calculates their sum.
\begin{Example}
@@ -539,7 +548,7 @@ and showing a greeting message to the user.
colback=shadecolor,
caption=A haskell interactive program,
label=lst:haskell,
- ]{demo.hs}
+ ]{pygmentex_demo.hs}
This is a rule:
@@ -552,9 +561,9 @@ Now a Pascal procedure:
linewidth=1.5pt,
font=\ttfamily\sffamily\large,
colback=yellow
- ]{demo.delphi}
+ ]{pygmentex_demo.delphi}
and a Pascal program
-\inputpygmented[lang=pascal,linenos,linenostart=5801]{demo.pas}
+\inputpygmented[lang=pascal,linenos,linenostart=5801]{pygmentex_demo.pas}
A Python code snippet:
@@ -565,7 +574,7 @@ A Python code snippet:
linenostep=3,
linewidth=1pt,
colback=lightgreen
- ]{demo.py}
+ ]{pygmentex_demo.py}
\section{Using code snippets in environments}
@@ -604,7 +613,7 @@ Here you can read the source code for a hand written lexical analyser
for the \emph{straight-line} programming language that I have developed
in Java.
-\inputpygmented[boxing method=mdframed,lang=java,sty=autumn,colback=red!8,font=\ttfamily\small,tabsize=2,frametitle=\emph{Ad hoc} lexical analyser]{demo.java}
+\inputpygmented[boxing method=mdframed,lang=java,sty=autumn,colback=red!8,font=\ttfamily\small,tabsize=2,frametitle=\emph{Ad hoc} lexical analyser]{pygmentex_demo.java}
\section{Some fancy examples using \texttt{tcolorbox}}
diff --git a/Master/texmf-dist/scripts/pygmentex/pygmentex.py b/Master/texmf-dist/scripts/pygmentex/pygmentex.py
index 42cef96faea..099b5a67eed 100755
--- a/Master/texmf-dist/scripts/pygmentex/pygmentex.py
+++ b/Master/texmf-dist/scripts/pygmentex/pygmentex.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@@ -8,11 +8,11 @@
PygmenTeX is a converter that do syntax highlighting of snippets of
source code extracted from a LaTeX file.
- :copyright: Copyright 2014 by José Romildo Malaquias
+ :copyright: Copyright 2020 by José Romildo Malaquias
:license: BSD, see LICENSE for details
"""
-__version__ = '0.8'
+__version__ = '0.10'
__docformat__ = 'restructuredtext'
import sys
@@ -27,6 +27,7 @@ from pygments.formatters.latex import LatexFormatter, escape_tex, _get_ttype_nam
from pygments.util import get_bool_opt, get_int_opt
from pygments.lexer import Lexer
from pygments.token import Token
+from pygments.util import guess_decode
###################################################
# The following code is in >=pygments-2.0
@@ -56,24 +57,24 @@ class EnhancedLatexFormatter(LatexFormatter):
realoutfile = outfile
outfile = StringIO()
- outfile.write(u'\\begin{Verbatim}[commandchars=\\\\\\{\\}')
+ outfile.write(r'\begin{Verbatim}[commandchars=\\\{\}')
if self.linenos:
start, step = self.linenostart, self.linenostep
- outfile.write(u',numbers=left' +
- (start and u',firstnumber=%d' % start or u'') +
- (step and u',stepnumber=%d' % step or u''))
+ outfile.write(',numbers=left' +
+ (start and ',firstnumber=%d' % start or '') +
+ (step and ',stepnumber=%d' % step or ''))
if self.mathescape or self.texcomments or self.escapeinside:
- outfile.write(u',codes={\\catcode`\\$=3\\catcode`\\^=7\\catcode`\\_=8}')
+ outfile.write(r',codes={\catcode`\$=3\catcode`\^=7\catcode`\_=8}')
if self.verboptions:
- outfile.write(u',' + self.verboptions)
- outfile.write(u']\n')
+ outfile.write(',' + self.verboptions)
+ outfile.write(']\n')
for ttype, value in tokensource:
if ttype in Token.Comment:
if self.texcomments:
# Try to guess comment starting lexeme and escape it ...
start = value[0:1]
- for i in xrange(1, len(value)):
+ for i in range(1, len(value)):
if start[0] != value[i]:
break
start += value[i]
@@ -129,7 +130,7 @@ class EnhancedLatexFormatter(LatexFormatter):
else:
outfile.write(value)
- outfile.write(u'\\end{Verbatim}\n')
+ outfile.write('\\end{Verbatim}\n')
if self.full:
realoutfile.write(DOC_TEMPLATE %
@@ -232,7 +233,7 @@ DISPLAY_LINENOS_SNIPPET_TEMPLATE = r'''
'''
-def pyg(outfile, n, opts, extra_opts, text, usedstyles, inline_delim = ''):
+def pyg(outfile, outencoding, n, opts, extra_opts, text, usedstyles, inline_delim = ''):
try:
lexer = get_lexer_by_name(opts['lang'])
except ClassNotFound as err:
@@ -260,27 +261,8 @@ def pyg(outfile, n, opts, extra_opts, text, usedstyles, inline_delim = ''):
if tabsize:
lexer.tabsize = tabsize
- encoding = opts['encoding']
- if encoding == 'guess':
- try:
- import chardet
- except ImportError:
- try:
- text = text.decode('utf-8')
- if text.startswith(u'\ufeff'):
- text = text[len(u'\ufeff'):]
- encoding = 'utf-8'
- except UnicodeDecodeError:
- text = text.decode('latin1')
- encoding = 'latin1'
- else:
- encoding = chardet.detect(text)['encoding']
- text = text.decode(encoding)
- else:
- text = text.decode(encoding)
-
lexer.encoding = ''
- _fmter.encoding = encoding
+ # _fmter.encoding = outencoding
stylename = opts['sty']
@@ -367,7 +349,7 @@ _re_input = re.compile(
r'^<@@pygmented@input@(\d+)\n(.*)\n([\s\S]*?)\n>@@pygmented@input@\1$',
re.MULTILINE)
-def convert(code, outfile):
+def convert(code, outfile, outencoding):
"""
Convert ``code``
"""
@@ -393,6 +375,7 @@ def convert(code, outfile):
m = _re_inline.match(code, pos)
if m:
pyg(outfile,
+ outencoding,
m.group(1),
parse_opts(opts.copy(), m.group(2)),
'',
@@ -405,6 +388,7 @@ def convert(code, outfile):
m = _re_display.match(code, pos)
if m:
pyg(outfile,
+ outencoding,
m.group(1),
parse_opts(opts.copy(), m.group(2)),
'',
@@ -415,15 +399,16 @@ def convert(code, outfile):
m = _re_input.match(code, pos)
if m:
+ opts_new = parse_opts(opts, m.group(2))
try:
- filecontents = open(m.group(3), 'rb').read()
+ filecontents, inencoding = read_input(m.group(3), opts_new['encoding'])
except Exception as err:
- sys.stderr.write('Error: cannot read input file: ')
- sys.stderr.write(str(err))
+ print('Error: cannot read input file: ', err, file=sys.stderr)
else:
pyg(outfile,
+ outencoding,
m.group(1),
- parse_opts(opts, m.group(2)),
+ opts_new,
"",
filecontents,
usedstyles)
@@ -435,6 +420,16 @@ def convert(code, outfile):
outfile.write(GENERIC_DEFINITIONS_2)
+def read_input(filename, encoding):
+ with open(filename, 'rb') as infp:
+ code = infp.read()
+
+ if not encoding or encoding == 'guess':
+ code, encoding = guess_decode(code)
+ else:
+ code = code.decode(encoding)
+
+ return code, encoding
USAGE = """\
@@ -486,7 +481,7 @@ def main(args = sys.argv):
return 0
if opts.pop('-V', None) is not None:
- print('PygmenTeX version %s, (c) 2010 by José Romildo.' % __version__)
+ print('PygmenTeX version %s, (c) 2020 by José Romildo.' % __version__)
return 0
if len(args) != 1:
@@ -494,10 +489,9 @@ def main(args = sys.argv):
return 2
infn = args[0]
try:
- code = open(infn, 'rb').read()
+ code, inencoding = read_input(infn, "guess")
except Exception as err:
- sys.stderr.write('Error: cannot read input file: ')
- sys.stderr.write(str(err))
+ print('Error: cannot read input file: ', err, file=sys.stderr)
return 1
outfn = opts.pop('-o', None)
@@ -507,11 +501,10 @@ def main(args = sys.argv):
try:
outfile = open(outfn, 'w')
except Exception as err:
- sys.stderr.write('Error: cannot open output file: ')
- sys.stderr.write(str(err))
+ print('Error: cannot open output file: ', err, file=sys.stderr)
return 1
- convert(code, outfile)
+ convert(code, outfile, inencoding)
return 0
diff --git a/Master/texmf-dist/tex/latex/pygmentex/pygmentex.sty b/Master/texmf-dist/tex/latex/pygmentex/pygmentex.sty
index a0ddd911b8d..60e7bcda30b 100644
--- a/Master/texmf-dist/tex/latex/pygmentex/pygmentex.sty
+++ b/Master/texmf-dist/tex/latex/pygmentex/pygmentex.sty
@@ -2,7 +2,7 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pygmentex}[2014/08/12 v0.8 A Pygmentex layer for LaTeX]
+\ProvidesPackage{pygmentex}[2020/12/21 v0.10 A Pygmentex layer for LaTeX]
\RequirePackage{fancyvrb}
\RequirePackage{color}
@@ -13,9 +13,9 @@
\RequirePackage{efbox}
\RequirePackage[framemethod=tikz]{mdframed}
-%\DeclareCaptionType[within=chapter]{code}[Listagem][Lista de listagens]
-\DeclareCaptionType{code}[Listagem][Lista de listagens]
-\captionsetup[code]{position=top}
+%\DeclareCaptionType[within=chapter]{pygcode}[Listagem][Lista de listagens]
+\DeclareCaptionType{pygcode}[Listagem][Lista de listagens]
+\captionsetup[pygcode]{position=top}
% =========================================================
% Auxiliary:
@@ -246,14 +246,14 @@
%
\ifdefined\pygmented@opt@label
\def\pygmented@title{%
- \captionof{code}{\label{\pygmented@opt@label}\pygmented@opt@caption}%
+ \captionof{pygcode}{\label{\pygmented@opt@label}\pygmented@opt@caption}%
% \nopagebreak
\vskip -0.7\baselineskip
}%
\else
\ifdefined\pygmented@opt@caption
\def\pygmented@title{%
- \captionof{code}{\pygmented@opt@caption}%
+ \captionof{pygcode}{\pygmented@opt@caption}%
% \nopagebreak
\vskip -0.7\baselineskip
}%