Parse post command argument insets (bug #8473)

This is now very easy with the new InsetArgument infrastructure.
This commit is contained in:
Georg Baum 2014-12-30 18:37:08 +01:00
parent d1e530cf5d
commit 1d4fb5ac7d
6 changed files with 130 additions and 7 deletions

View File

@ -34,6 +34,7 @@ TEST_FILES = \
test/foo.png \
test/test-insets.tex \
test/test.ltx \
test/test-memoir.tex \
test/test-modules.tex \
test/test-refstyle-theorems.tex \
test/test-scr.tex \
@ -53,6 +54,7 @@ TEST_RESULTS = \
test/Dummy~Document.lyx.lyx \
test/test-insets.lyx.lyx \
test/test.lyx.lyx \
test/test-memoir.lyx.lyx \
test/test-modules.lyx.lyx \
test/test-refstyle-theorems.lyx.lyx \
test/test-scr.lyx.lyx \

View File

@ -15,6 +15,7 @@ set(_tex_tests test.ltx
CJK.tex
CJKutf8.tex
test-insets.tex
test-memoir.tex
test-modules.tex
test-refstyle-theorems.tex
test-scr.tex

View File

@ -75,6 +75,7 @@ def main(argv):
'CJK.tex', \
'CJKutf8.tex', \
'test-insets.tex', \
'test-memoir.tex', \
'test-modules.tex', \
'test-refstyle-theorems.tex', \
'test-scr.tex', \

View File

@ -0,0 +1,95 @@
#LyX file created by tex2lyx 2.2
\lyxformat 479
\begin_document
\begin_header
\textclass memoir
\begin_preamble
\usepackage{babel}
\end_preamble
\options oldfontcommands
\use_default_options false
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding iso8859-15
\fontencoding T1
\font_roman default
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\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
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\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 Epigraph
epigraph
\begin_inset Argument post:1
status collapsed
\begin_layout Standard
source
\end_layout
\end_inset
\end_layout
\end_body
\end_document

View File

@ -0,0 +1,10 @@
\documentclass[oneside,english,oldfontcommands]{memoir}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\begin{document}
\epigraph{epigraph}{source}
\end{document}

View File

@ -47,7 +47,7 @@ namespace lyx {
namespace {
void output_arguments(ostream &, Parser &, bool, bool, Context &,
void output_arguments(ostream &, Parser &, bool, bool, bool, Context &,
Layout::LaTeXArgMap const &);
}
@ -64,8 +64,12 @@ void parse_text_in_inset(Parser & p, ostream & os, unsigned flags, bool outer,
else
newcontext.font = context.font;
if (layout)
output_arguments(os, p, outer, false, newcontext, layout->latexargs());
output_arguments(os, p, outer, false, false, newcontext,
layout->latexargs());
parse_text(p, os, flags, outer, newcontext);
if (layout)
output_arguments(os, p, outer, false, true, newcontext,
layout->postcommandargs());
newcontext.check_end_layout(os);
}
@ -623,7 +627,7 @@ void skip_spaces_braces(Parser & p, bool keepws = false)
}
void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout,
void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout, bool post,
Context & context, Layout::LaTeXArgMap const & latexargs)
{
if (need_layout) {
@ -646,6 +650,8 @@ void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout,
need_layout = false;
}
begin_inset(os, "Argument ");
if (post)
os << "post:";
os << i << "\nstatus collapsed\n\n";
parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
end_inset(os);
@ -659,6 +665,8 @@ void output_arguments(ostream & os, Parser & p, bool outer, bool need_layout,
need_layout = false;
}
begin_inset(os, "Argument ");
if (post)
os << "post:";
os << i << "\nstatus collapsed\n\n";
parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
end_inset(os);
@ -691,8 +699,11 @@ void output_command_layout(ostream & os, Parser & p, bool outer,
context.need_end_deeper = true;
}
context.check_deeper(os);
output_arguments(os, p, outer, true, context, context.layout->latexargs());
output_arguments(os, p, outer, true, false, context,
context.layout->latexargs());
parse_text(p, os, FLAG_ITEM, outer, context);
output_arguments(os, p, outer, false, true, context,
context.layout->postcommandargs());
context.check_end_layout(os);
if (parent_context.deeper_paragraph) {
// We must suppress the "end deeper" because we
@ -1671,10 +1682,13 @@ void parse_environment(Parser & p, ostream & os, bool outer,
// Unfortunately LyX can't handle arguments of list arguments (bug 7468):
// It is impossible to place anything after the environment name,
// but before the first \\item.
if (context.layout->latextype == LATEX_ENVIRONMENT) {
output_arguments(os, p, outer, false, context, context.layout->latexargs());
}
if (context.layout->latextype == LATEX_ENVIRONMENT)
output_arguments(os, p, outer, false, false, context,
context.layout->latexargs());
parse_text(p, os, FLAG_END, outer, context);
if (context.layout->latextype == LATEX_ENVIRONMENT)
output_arguments(os, p, outer, false, true, context,
context.layout->postcommandargs());
context.check_end_layout(os);
if (parent_context.deeper_paragraph) {
// We must suppress the "end deeper" because we