mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Improved support for docbook export in inset text.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2975 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2dd919eeb8
commit
83e7c2cff7
@ -1,3 +1,15 @@
|
||||
2001-11-07 José Matos <jamatos@fep.up.pt>
|
||||
|
||||
* buffer.h:
|
||||
* buffer.C (sgmlError): linuxDocError renamed, and made public, added
|
||||
const qualifier.
|
||||
|
||||
* buffer.C (sgmlOpenTag):
|
||||
* buffer.C (sgmlCloseTag): removed debug info.
|
||||
|
||||
* buffer.h (sgmlOpenTag):
|
||||
* buffer.h (sgmlCloseTag): made public.
|
||||
|
||||
2001-11-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* buffer.C (saveParamsAsDefaults):
|
||||
|
24
src/buffer.C
24
src/buffer.C
@ -2509,8 +2509,8 @@ void Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type depth,
|
||||
string const & latexname) const
|
||||
{
|
||||
if (!latexname.empty() && latexname != "!-- --")
|
||||
os << "<!-- " << depth << " -->" << "<" << latexname << ">";
|
||||
//os << string(depth, ' ') << "<" << latexname << ">\n";
|
||||
//os << "<!-- " << depth << " -->" << "<" << latexname << ">";
|
||||
os << string(depth, ' ') << "<" << latexname << ">\n";
|
||||
}
|
||||
|
||||
|
||||
@ -2518,8 +2518,8 @@ void Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type depth,
|
||||
string const & latexname) const
|
||||
{
|
||||
if (!latexname.empty() && latexname != "!-- --")
|
||||
os << "<!-- " << depth << " -->" << "</" << latexname << ">\n";
|
||||
//os << string(depth, ' ') << "</" << latexname << ">\n";
|
||||
//os << "<!-- " << depth << " -->" << "</" << latexname << ">\n";
|
||||
os << string(depth, ' ') << "</" << latexname << ">\n";
|
||||
}
|
||||
|
||||
|
||||
@ -2616,9 +2616,9 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
|
||||
|
||||
case LATEX_COMMAND:
|
||||
if (depth!= 0)
|
||||
linuxDocError(par, 0,
|
||||
_("Error : Wrong depth for"
|
||||
" LatexType Command.\n"));
|
||||
sgmlError(par, 0,
|
||||
_("Error : Wrong depth for"
|
||||
" LatexType Command.\n"));
|
||||
|
||||
if (!environment_stack[depth].empty()){
|
||||
sgmlCloseTag(ofs, depth,
|
||||
@ -2953,8 +2953,8 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
|
||||
|
||||
|
||||
// Print an error message.
|
||||
void Buffer::linuxDocError(Paragraph * par, int pos,
|
||||
string const & message)
|
||||
void Buffer::sgmlError(Paragraph * par, int pos,
|
||||
string const & message) const
|
||||
{
|
||||
// insert an error marker in text
|
||||
InsetError * new_inset = new InsetError(message);
|
||||
@ -3080,9 +3080,9 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
|
||||
|
||||
case LATEX_COMMAND:
|
||||
if (depth != 0)
|
||||
linuxDocError(par, 0,
|
||||
_("Error : Wrong depth for "
|
||||
"LatexType Command.\n"));
|
||||
sgmlError(par, 0,
|
||||
_("Error : Wrong depth for "
|
||||
"LatexType Command.\n"));
|
||||
|
||||
command_name = style.latexname();
|
||||
|
||||
|
30
src/buffer.h
30
src/buffer.h
@ -167,9 +167,9 @@ public:
|
||||
void simpleDocBookOnePar(std::ostream &, string & extra,
|
||||
Paragraph * par, int & desc_on,
|
||||
Paragraph::depth_type depth) const ;
|
||||
|
||||
///
|
||||
int runChktex();
|
||||
///
|
||||
void simpleLinuxDocOnePar(std::ostream & os, Paragraph * par,
|
||||
Paragraph::depth_type depth);
|
||||
|
||||
///
|
||||
void makeLinuxDocFile(string const & filename,
|
||||
@ -177,10 +177,21 @@ public:
|
||||
///
|
||||
void makeDocBookFile(string const & filename,
|
||||
bool nice, bool only_body = false);
|
||||
/// Open SGML/XML tag.
|
||||
void sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth,
|
||||
string const & latexname) const;
|
||||
/// Closes SGML/XML tag.
|
||||
void sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth,
|
||||
string const & latexname) const;
|
||||
///
|
||||
void sgmlError(Paragraph * par, int pos,
|
||||
string const & message) const;
|
||||
|
||||
/// returns the main language for the buffer (document)
|
||||
Language const * getLanguage() const;
|
||||
///
|
||||
int runChktex();
|
||||
///
|
||||
bool isLyxClean() const;
|
||||
///
|
||||
bool isBakClean() const;
|
||||
@ -316,19 +327,6 @@ public:
|
||||
/// Used when typesetting to place errorboxes.
|
||||
TexRow texrow;
|
||||
private:
|
||||
/// Open SGML/XML tag.
|
||||
void sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth,
|
||||
string const & latexname) const;
|
||||
/// Closes SGML/XML tag.
|
||||
void sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth,
|
||||
string const & latexname) const;
|
||||
///
|
||||
void linuxDocError(Paragraph * par, int pos,
|
||||
string const & message);
|
||||
///
|
||||
void simpleLinuxDocOnePar(std::ostream & os, Paragraph * par,
|
||||
Paragraph::depth_type depth);
|
||||
|
||||
/// is save needed
|
||||
mutable bool lyx_clean;
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
2001-11-03 José Matos <jamatos@novalis.fc.up.pt>
|
||||
2001-11-07 José Matos <jamatos@fep.up.pt>
|
||||
|
||||
* /insetindex.C: added header file for std::ostream.
|
||||
* insettext.C (docbook): full support for paragraphs inside insettext.
|
||||
|
||||
2001-11-06 José Matos <jamatos@novalis.fc.up.pt>
|
||||
|
||||
* insetindex.C: added header file for std::ostream.
|
||||
|
||||
2001-11-03 José Matos <jamatos@fep.up.pt>
|
||||
|
||||
|
@ -59,6 +59,7 @@ using std::endl;
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::make_pair;
|
||||
using std::vector;
|
||||
|
||||
extern unsigned char getCurrentTextClass(Buffer *);
|
||||
extern bool math_insert_greek(BufferView *, char);
|
||||
@ -1364,12 +1365,184 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
|
||||
{
|
||||
Paragraph * p = par;
|
||||
unsigned int lines = 0;
|
||||
int desc = 0;
|
||||
|
||||
vector<string> environment_stack(10);
|
||||
vector<string> environment_inner(10);
|
||||
|
||||
string tmp;
|
||||
int const command_depth = 0;
|
||||
string item_name;
|
||||
|
||||
Paragraph::depth_type depth = 0; // paragraph depth
|
||||
|
||||
while (p) {
|
||||
buf->simpleDocBookOnePar(os, tmp, p, desc, 0);
|
||||
string sgmlparam;
|
||||
int desc_on = 0; // description mode
|
||||
|
||||
LyXLayout const & style =
|
||||
textclasslist.Style(buf->params.textclass,
|
||||
p->layout);
|
||||
|
||||
// environment tag closing
|
||||
for (; depth > p->params().depth(); --depth) {
|
||||
if (environment_inner[depth] != "!-- --") {
|
||||
item_name = "listitem";
|
||||
buf->sgmlCloseTag(os, command_depth + depth,
|
||||
item_name);
|
||||
if (environment_inner[depth] == "varlistentry")
|
||||
buf->sgmlCloseTag(os, depth+command_depth,
|
||||
environment_inner[depth]);
|
||||
}
|
||||
buf->sgmlCloseTag(os, depth + command_depth,
|
||||
environment_stack[depth]);
|
||||
environment_stack[depth].erase();
|
||||
environment_inner[depth].erase();
|
||||
}
|
||||
|
||||
if (depth == p->params().depth()
|
||||
&& environment_stack[depth] != style.latexname()
|
||||
&& !environment_stack[depth].empty()) {
|
||||
if (environment_inner[depth] != "!-- --") {
|
||||
item_name= "listitem";
|
||||
buf->sgmlCloseTag(os, command_depth+depth,
|
||||
item_name);
|
||||
if (environment_inner[depth] == "varlistentry")
|
||||
buf->sgmlCloseTag(os,
|
||||
depth + command_depth,
|
||||
environment_inner[depth]);
|
||||
}
|
||||
|
||||
buf->sgmlCloseTag(os, depth + command_depth,
|
||||
environment_stack[depth]);
|
||||
|
||||
environment_stack[depth].erase();
|
||||
environment_inner[depth].erase();
|
||||
}
|
||||
|
||||
// Write opening SGML tags.
|
||||
switch (style.latextype) {
|
||||
case LATEX_PARAGRAPH:
|
||||
buf->sgmlOpenTag(os, depth + command_depth,
|
||||
style.latexname());
|
||||
break;
|
||||
|
||||
case LATEX_COMMAND:
|
||||
buf->sgmlError(p, 0,
|
||||
_("Error : LatexType Command not allowed here.\n"));
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case LATEX_ENVIRONMENT:
|
||||
case LATEX_ITEM_ENVIRONMENT:
|
||||
if (depth < p->params().depth()) {
|
||||
depth = p->params().depth();
|
||||
environment_stack[depth].erase();
|
||||
}
|
||||
|
||||
if (environment_stack[depth] != style.latexname()) {
|
||||
if(environment_stack.size() == depth + 1) {
|
||||
environment_stack.push_back("!-- --");
|
||||
environment_inner.push_back("!-- --");
|
||||
}
|
||||
environment_stack[depth] = style.latexname();
|
||||
environment_inner[depth] = "!-- --";
|
||||
buf->sgmlOpenTag(os, depth + command_depth,
|
||||
environment_stack[depth]);
|
||||
} else {
|
||||
if (environment_inner[depth] != "!-- --") {
|
||||
item_name= "listitem";
|
||||
buf->sgmlCloseTag(os,
|
||||
command_depth + depth,
|
||||
item_name);
|
||||
if (environment_inner[depth] == "varlistentry")
|
||||
buf->sgmlCloseTag(os,
|
||||
depth + command_depth,
|
||||
environment_inner[depth]);
|
||||
}
|
||||
}
|
||||
|
||||
if (style.latextype == LATEX_ENVIRONMENT) {
|
||||
if (!style.latexparam().empty()) {
|
||||
if(style.latexparam() == "CDATA")
|
||||
os << "<![CDATA[";
|
||||
else
|
||||
buf->sgmlOpenTag(os, depth + command_depth,
|
||||
style.latexparam());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
desc_on = (style.labeltype == LABEL_MANUAL);
|
||||
|
||||
if (desc_on)
|
||||
environment_inner[depth]= "varlistentry";
|
||||
else
|
||||
environment_inner[depth]= "listitem";
|
||||
|
||||
buf->sgmlOpenTag(os, depth + 1 + command_depth,
|
||||
environment_inner[depth]);
|
||||
|
||||
if (desc_on) {
|
||||
item_name= "term";
|
||||
buf->sgmlOpenTag(os, depth + 1 + command_depth,
|
||||
item_name);
|
||||
} else {
|
||||
item_name= "para";
|
||||
buf->sgmlOpenTag(os, depth + 1 + command_depth,
|
||||
item_name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
buf->sgmlOpenTag(os, depth + command_depth,
|
||||
style.latexname());
|
||||
break;
|
||||
}
|
||||
|
||||
string extra_par;
|
||||
buf->simpleDocBookOnePar(os, extra_par, p, desc_on,
|
||||
depth + 1 + command_depth);
|
||||
p = p->next();
|
||||
|
||||
string end_tag;
|
||||
// write closing SGML tags
|
||||
switch (style.latextype) {
|
||||
case LATEX_ENVIRONMENT:
|
||||
if (!style.latexparam().empty()) {
|
||||
if(style.latexparam() == "CDATA")
|
||||
os << "]]>";
|
||||
else
|
||||
buf->sgmlCloseTag(os, depth + command_depth,
|
||||
style.latexparam());
|
||||
}
|
||||
break;
|
||||
case LATEX_ITEM_ENVIRONMENT:
|
||||
if (desc_on == 1) break;
|
||||
end_tag= "para";
|
||||
buf->sgmlCloseTag(os, depth + 1 + command_depth, end_tag);
|
||||
break;
|
||||
case LATEX_PARAGRAPH:
|
||||
buf->sgmlCloseTag(os, depth + command_depth, style.latexname());
|
||||
break;
|
||||
default:
|
||||
buf->sgmlCloseTag(os, depth + command_depth, style.latexname());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Close open tags
|
||||
for (int d = depth; d >= 0; --d) {
|
||||
if (!environment_stack[depth].empty()) {
|
||||
if (environment_inner[depth] != "!-- --") {
|
||||
item_name = "listitem";
|
||||
buf->sgmlCloseTag(os, command_depth + depth,
|
||||
item_name);
|
||||
if (environment_inner[depth] == "varlistentry")
|
||||
buf->sgmlCloseTag(os, depth + command_depth,
|
||||
environment_inner[depth]);
|
||||
}
|
||||
|
||||
buf->sgmlCloseTag(os, depth + command_depth,
|
||||
environment_stack[depth]);
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
Loading…
Reference in New Issue
Block a user