]> git.lyx.org Git - lyx.git/commitdiff
Tex2lyx tests: Added minted testcase from Enrico Forestieri
authorKornel Benko <kornel@lyx.org>
Sat, 17 Jun 2017 14:55:57 +0000 (16:55 +0200)
committerKornel Benko <kornel@lyx.org>
Sat, 17 Jun 2017 17:12:17 +0000 (19:12 +0200)
src/tex2lyx/Makefile.am
src/tex2lyx/test/CMakeLists.txt
src/tex2lyx/test/test-minted.lyx.lyx [new file with mode: 0644]
src/tex2lyx/test/test-minted.tex [new file with mode: 0644]

index 7089ea420c18aefffec16a34b09e038490712d23..7a744abc0b7de57a28ad829ed58aee16eba4562f 100644 (file)
@@ -36,6 +36,7 @@ TEST_FILES = \
        test/test-insets-basic.tex \
        test/test.ltx \
        test/test-memoir.tex \
+       test/test-minted.tex \
        test/test-modules.tex \
        test/test-refstyle-theorems.tex \
        test/test-scr.tex \
@@ -57,6 +58,7 @@ TEST_RESULTS = \
        test/test-insets-basic.lyx.lyx \
        test/test.lyx.lyx \
        test/test-memoir.lyx.lyx \
+       test/test-minted.lyx.lyx \
        test/test-modules.lyx.lyx \
        test/test-refstyle-theorems.lyx.lyx \
        test/test-scr.lyx.lyx \
index 1a6f34bae3741bf0423da9680e6dfd3894223431..643b017bb297a11533368ac8a48eee3c32f25c0a 100644 (file)
@@ -18,6 +18,7 @@ set(_tex_tests test.ltx
                test-insets-basic.tex
                test-insets.tex
                test-memoir.tex
+              test-minted.tex
                test-modules.tex
                test-refstyle-theorems.tex
                test-scr.tex
diff --git a/src/tex2lyx/test/test-minted.lyx.lyx b/src/tex2lyx/test/test-minted.lyx.lyx
new file mode 100644 (file)
index 0000000..7e4c454
--- /dev/null
@@ -0,0 +1,541 @@
+#LyX file created by tex2lyx 2.3
+\lyxformat 544
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin roundtrip
+\textclass article
+\begin_preamble
+%% Do not edit unless you really know what you are doing.
+
+
+
+\end_preamble
+\use_default_options false
+\maintain_unincluded_children false
+\language english
+\language_package none
+\inputencoding iso8859-15
+\fontencoding T1
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "default"
+\font_math "auto" "auto"
+\font_default_family default
+\use_non_tex_fonts false
+\font_sc false
+\font_osf false
+\font_sf_scale 100 100
+\font_tt_scale 100 100
+\use_microtype false
+\use_dash_ligatures true
+\graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\paperfontsize 12
+\spacing single
+\use_hyperref false
+\papersize a4paper
+\use_geometry false
+\use_package amsmath 1
+\use_package amssymb 0
+\use_package cancel 0
+\use_package esint 1
+\use_package mathdots 0
+\use_package mathtools 0
+\use_package mhchem 0
+\use_package stackrel 0
+\use_package stmaryrd 0
+\use_package undertilde 0
+\cite_engine basic
+\cite_engine_type default
+\biblio_style plain
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 0
+\use_minted 1
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tracking_changes false
+\output_changes false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
+\end_header
+
+\begin_body
+
+\begin_layout Standard
+
+\begin_inset CommandInset toc
+LatexCommand lstlistoflistings
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Minted Listings
+\end_layout
+
+\begin_layout Standard
+Inline: 
+\begin_inset listings
+lstparams "style=bw,language=C++"
+inline true
+status collapsed
+
+\begin_layout Plain Layout
+int a=5;
+\end_layout
+
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+ Float (Listing
+\begin_inset space ~
+
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "Example-Listing"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+):
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset listings
+lstparams "language=Python,float=h"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+# Example listing float
+\end_layout
+
+\begin_layout Plain Layout
+def func(param):
+\end_layout
+
+\begin_layout Plain Layout
+    'this is a python function'
+\end_layout
+
+\begin_layout Plain Layout
+    pass
+\end_layout
+
+\begin_layout Plain Layout
+
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+Example Listing float
+\begin_inset CommandInset label
+LatexCommand label
+name "Example-Listing"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Here is an example listing with left line numbering, language 
+\begin_inset Quotes eld
+\end_inset
+
+Python
+\begin_inset Quotes erd
+\end_inset
+
+ and 
+\begin_inset Quotes eld
+\end_inset
+
+Space
+\begin_inset space ~
+
+\end_inset
+
+as
+\begin_inset space ~
+
+\end_inset
+
+symbol
+\begin_inset Quotes erd
+\end_inset
+
+, range lines from 4 to end:
+\end_layout
+
+\begin_layout Standard
+
+\begin_inset listings
+lstparams "firstline=4,numbers=left,showspaces=true,language=Python"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+def func(param):
+\end_layout
+
+\begin_layout Plain Layout
+    'this is a python function'
+\end_layout
+
+\begin_layout Plain Layout
+    pass
+\end_layout
+
+\begin_layout Plain Layout
+def func(param):
+\end_layout
+
+\begin_layout Plain Layout
+    'This is a German word: Tschuess'
+\end_layout
+
+\begin_layout Plain Layout
+    pass
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+A floating one-liner with [h] placement and without caption: 
+\begin_inset listings
+lstparams "fontfamily=tt,fontsize={\large},bgcolor=lightgray,language=ABAP,float=h"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+hello
+\end_layout
+
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Another inline listing: 
+\begin_inset listings
+lstparams "language=TeX"
+inline true
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+begin{centering} hello
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+A non-floating listing with line frames and a top caption (Listing
+\begin_inset space ~
+
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "hello-world"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+):  
+\begin_inset listings
+lstparams "numbers=left,frame=lines,language=C"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+An example C program
+\begin_inset CommandInset label
+LatexCommand label
+name "hello-world"
+
+\end_inset
+
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Plain Layout
+int main()
+\end_layout
+
+\begin_layout Plain Layout
+{
+\end_layout
+
+\begin_layout Plain Layout
+    printf("Hello world!
+\backslash
+n");
+\end_layout
+
+\begin_layout Plain Layout
+    return 0;
+\end_layout
+
+\begin_layout Plain Layout
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+A non-floating listing with line frames and a bottom caption (Listing
+\begin_inset space ~
+
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "func"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+): 
+\begin_inset listings
+lstparams "numbers=left,frame=lines,language=Fortran"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+subroutine incr(i)
+\end_layout
+
+\begin_layout Plain Layout
+  integer :: i
+\end_layout
+
+\begin_layout Plain Layout
+  i = i + 1 
+\end_layout
+
+\begin_layout Plain Layout
+  return 
+\end_layout
+
+\begin_layout Plain Layout
+end subroutine function
+\end_layout
+
+\begin_layout Plain Layout
+
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+
+\begin_inset CommandInset label
+LatexCommand label
+name "func"
+
+\end_inset
+
+A Fortran subroutine
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+A framed floating listing with a caption and a label (Listing
+\begin_inset space ~
+
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "python1"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+): 
+\begin_inset listings
+lstparams "frame=single,language=Python,float=h"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+def boring(args = None):
+\end_layout
+
+\begin_layout Plain Layout
+    pass
+\end_layout
+
+\begin_layout Plain Layout
+
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+A Python function.
+\begin_inset CommandInset label
+LatexCommand label
+name "python1"
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The same framed floating listing with a caption, a label and a stray math equation (Listing
+\begin_inset space ~
+
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "python2"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+): \begin_inset listings
+lstparams "frame=single,language=Python,float=h"
+inline false
+status collapsed
+
+\begin_layout Plain Layout
+def boring(args = None):
+\end_layout
+
+\begin_layout Plain Layout
+    pass
+\end_layout
+
+\begin_layout Plain Layout
+
+\begin_inset Caption Standard
+
+\begin_layout Plain Layout
+The previous Python function.
+\begin_inset CommandInset label
+LatexCommand label
+name "python2"
+
+\end_inset
+
+
+\begin_inset Formula $y=f(x)$
+\end_inset
+
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_body
+\end_document
diff --git a/src/tex2lyx/test/test-minted.tex b/src/tex2lyx/test/test-minted.tex
new file mode 100644 (file)
index 0000000..a6efa4c
--- /dev/null
@@ -0,0 +1,94 @@
+%% Do not edit unless you really know what you are doing.
+\documentclass[a4paper,12pt]{article}
+\usepackage[T1]{fontenc}
+\usepackage[latin9]{inputenc}
+\usepackage{minted}
+
+\begin{document}
+
+\listoflistings
+
+\section{Minted Listings}
+
+Inline: \mintinline[style=bw]{C++}!int a=5;!\\
+Float (Listing~\ref{Example-Listing}):
+
+\begin{listing}[h]
+\begin{minted}{Python}
+# Example listing float
+def func(param):
+    'this is a python function'
+    pass
+\end{minted}
+\caption{Example Listing float}
+\label{Example-Listing}
+\end{listing}
+
+Here is an example listing with left line numbering, language ``Python''
+and ``Space~as~symbol'', range lines from 4 to end:
+
+\begin{minted}[firstline=4,numbers=left,showspaces=true]{Python}
+def func(param):
+    'this is a python function'
+    pass
+def func(param):
+    'This is a German word: Tschuess'
+    pass
+\end{minted}
+
+A floating one-liner with [h] placement and without caption:
+\begin{listing}[h]
+\begin{minted}[fontfamily=tt,fontsize={\large},bgcolor=lightgray]{ABAP}
+hello
+\end{minted}
+\end{listing}
+
+Another inline listing:
+\mintinline{TeX}!\begin{centering} hello!
+
+A non-floating listing with line frames and a top caption
+(Listing~\ref{hello-world}):
+\lyxmintcaption[t]{An example C program\label{hello-world}}
+\begin{minted}[numbers=left,frame=lines]{C}
+int main()
+{
+    printf("Hello world!\n");
+    return 0;
+}
+\end{minted}
+
+A non-floating listing with line frames and a bottom caption
+(Listing~\ref{func}):
+\begin{minted}[numbers=left,frame=lines]{Fortran}
+subroutine incr(i)
+  integer :: i
+  i = i + 1 
+  return 
+end subroutine function
+\end{minted}
+\lyxmintcaption[b]{\label{func}A Fortran subroutine}
+
+A framed floating listing with a caption and a label (Listing~\ref{python1}):
+\begin{listing}[h]
+    \begin{minted}[frame=single]{Python}
+def boring(args = None):
+    pass
+\end{minted}
+\caption{A Python function.}
+\label{python1}
+\end{listing}
+
+
+The same framed floating listing with a caption, a label and a stray math
+equation (Listing~\ref{python2}):
+\begin{listing}[h]
+$y=f(x)$
+\begin{minted}[frame=single]{Python}
+def boring(args = None):
+    pass
+\end{minted}
+\caption{The previous Python function.}
+\label{python2}
+\end{listing}
+
+\end{document}