mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Update chunk handling to use new inset
At the same time, rename parse_noweb to parse_chunk.
This commit is contained in:
parent
63c193afef
commit
a2546357eb
@ -1993,43 +1993,55 @@ void copy_file(FileName const & src, string dstname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Parse a NoWeb Chunk section. The initial "<<" is already parsed.
|
/// Parse a literate Chunk section. The initial "<<" is already parsed.
|
||||||
bool parse_noweb(Parser & p, ostream & os, Context & context)
|
bool parse_chunk(Parser & p, ostream & os, Context & context)
|
||||||
{
|
{
|
||||||
// check whether a chunk is possible here.
|
// check whether a chunk is possible here.
|
||||||
if (!context.new_layout_allowed ||
|
if (!context.textclass.hasInsetLayout(from_ascii("Flex:Chunk"))) {
|
||||||
!context.textclass.hasLayout(from_ascii("Chunk"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.pushPosition();
|
p.pushPosition();
|
||||||
|
|
||||||
// read the parameters
|
// read the parameters
|
||||||
Parser::Arg stuff = p.verbatimStuff(">>=", false);
|
Parser::Arg const params = p.verbatimStuff(">>=\n", false);
|
||||||
if (!stuff.first) {
|
if (!params.first) {
|
||||||
p.popPosition();
|
p.popPosition();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string chunk = "<<" + stuff.second + ">>="
|
|
||||||
+ p.verbatimStuff("\n").second + '\n';
|
|
||||||
|
|
||||||
stuff = p.verbatimStuff("\n@");
|
Parser::Arg const code = p.verbatimStuff("\n@");
|
||||||
if (!stuff.first) {
|
if (!code.first) {
|
||||||
p.popPosition();
|
p.popPosition();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
chunk += stuff.second + "\n@";
|
string const post_chunk = p.verbatimStuff("\n").second + '\n';
|
||||||
string post_chunk = p.verbatimStuff("\n").second + '\n';
|
|
||||||
if (post_chunk[0] != ' ' && post_chunk[0] != '\n') {
|
if (post_chunk[0] != ' ' && post_chunk[0] != '\n') {
|
||||||
p.popPosition();
|
p.popPosition();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
chunk += post_chunk;
|
// The last newline read is important for paragraph handling
|
||||||
|
p.putback();
|
||||||
|
p.deparse();
|
||||||
|
|
||||||
context.new_paragraph(os);
|
//cerr << "params=[" << params.second << "], code=[" << code.second << "]" <<endl;
|
||||||
Context newcontext(true, context.textclass,
|
// We must have a valid layout before outputting the Chunk inset.
|
||||||
&context.textclass[from_ascii("Chunk")]);
|
context.check_layout(os);
|
||||||
output_ert(os, chunk, newcontext);
|
Context chunkcontext(true, context.textclass);
|
||||||
|
chunkcontext.layout = &context.textclass.plainLayout();
|
||||||
|
begin_inset(os, "Flex Chunk");
|
||||||
|
os << "\nstatus open\n";
|
||||||
|
if (!params.second.empty()) {
|
||||||
|
chunkcontext.check_layout(os);
|
||||||
|
Context paramscontext(true, context.textclass);
|
||||||
|
paramscontext.layout = &context.textclass.plainLayout();
|
||||||
|
begin_inset(os, "Argument 1");
|
||||||
|
os << "\nstatus open\n";
|
||||||
|
output_ert(os, params.second, paramscontext);
|
||||||
|
end_inset(os);
|
||||||
|
}
|
||||||
|
output_ert(os, code.second, chunkcontext);
|
||||||
|
end_inset(os);
|
||||||
|
|
||||||
p.dropPosition();
|
p.dropPosition();
|
||||||
return true;
|
return true;
|
||||||
@ -2305,16 +2317,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
|
|
||||||
else if (t.asInput() == "<"
|
else if (t.asInput() == "<"
|
||||||
&& p.next_token().asInput() == "<") {
|
&& p.next_token().asInput() == "<") {
|
||||||
bool has_noweb = false;
|
bool has_chunk = false;
|
||||||
if (noweb_mode) {
|
if (noweb_mode) {
|
||||||
p.pushPosition();
|
p.pushPosition();
|
||||||
p.get_token();
|
p.get_token();
|
||||||
has_noweb = parse_noweb(p, os, context);
|
has_chunk = parse_chunk(p, os, context);
|
||||||
if (!has_noweb)
|
if (!has_chunk)
|
||||||
p.popPosition();
|
p.popPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_noweb) {
|
if (!has_chunk) {
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
begin_inset(os, "Quotes ");
|
begin_inset(os, "Quotes ");
|
||||||
//FIXME: this is a right danish quote;
|
//FIXME: this is a right danish quote;
|
||||||
|
@ -31,7 +31,7 @@ extern char const * const lyx_version_info;
|
|||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
#define LYX_FORMAT_LYX 474 // rgh: dummy format change for Chunk switch
|
#define LYX_FORMAT_LYX 474 // rgh: dummy format change for Chunk switch
|
||||||
#define LYX_FORMAT_TEX2LYX 473
|
#define LYX_FORMAT_TEX2LYX 474
|
||||||
|
|
||||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user