From 93ea4edddfd93fd8209d146350c673088c992f9d Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Fri, 14 Nov 2003 14:05:03 +0000 Subject: [PATCH] XML sanitation git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8087 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 6 ++ lib/layouts/db_stdsections.inc | 25 +++++--- lib/layouts/db_stdtitle.inc | 10 +-- src/ChangeLog | 6 ++ src/lyxlayout.C | 107 +++++++++++++++++++-------------- src/lyxlayout.h | 6 ++ src/output_docbook.C | 23 +++---- 7 files changed, 110 insertions(+), 73 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 64432c8274..ed03c36141 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2003-11-14 Martin Vermeer + + * layouts/db_stdsections.inc: + * layouts/db_stdtitle.inc: XML sanitation: new layout + parameters InnerTag and CommandDepth + 2003-11-13 Angus Leeming * CREDITS: added Ling Li. diff --git a/lib/layouts/db_stdsections.inc b/lib/layouts/db_stdsections.inc index dd5acb8a21..711c4aaf50 100644 --- a/lib/layouts/db_stdsections.inc +++ b/lib/layouts/db_stdsections.inc @@ -1,8 +1,9 @@ # Textclass definition file for docbook. # Author : José Abílio Oliveira Matos +# Modified by Martin Vermeer # This file is the counterpart of stdsections.inc -# It is desireable, as far as possible, to have the same look and feeling for +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. Input stdsections.inc @@ -10,47 +11,55 @@ Input stdsections.inc Style Part LatexType Command LatexName part - LatexParam "0|" + InnerTag "title" + CommandDepth 0 End Style Chapter LatexType Command LatexName chapter - LatexParam "1|" + InnerTag "title" + CommandDepth 1 End Style Section LatexType Command LatexName sect1 - LatexParam "2|" + InnerTag "title" + CommandDepth 2 End Style Subsection LatexType Command LatexName sect2 - LatexParam "3|" + InnerTag "title" + CommandDepth 3 End Style Subsubsection LatexType Command LatexName sect3 - LatexParam "4|" + InnerTag "title" + CommandDepth 4 End Style Paragraph LatexType Command LatexName sect4 - LatexParam "5|" + InnerTag "title" + CommandDepth 5 End Style Subparagraph LatexType Command LatexName sect5 - LatexParam "6|" + InnerTag "title" + CommandDepth 6 End + diff --git a/lib/layouts/db_stdtitle.inc b/lib/layouts/db_stdtitle.inc index 248e39e591..e1025fa254 100644 --- a/lib/layouts/db_stdtitle.inc +++ b/lib/layouts/db_stdtitle.inc @@ -1,8 +1,9 @@ # Textclass definition file for docbook. # Author : José Abílio Oliveira Matos - -# This file is the counterpart of stdstile.inc -# It is desireable, as far as possible, to have the same look and feeling for +# Modified Martin Vermeer +# +# This file is the counterpart of stdstyle.inc +# It is desirable, as far as possible, to have the same look and feel for # related layouts in latex and docbook. Input stdtitle.inc @@ -11,7 +12,8 @@ Input stdtitle.inc Style Title LatexType Command LatexName articleinfo - LatexParam "2|" + CommandDepth 2 + InnerTag "title" End diff --git a/src/ChangeLog b/src/ChangeLog index 0823a92919..7c6fd15d41 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-11-14 Martin Vermeer + + * lyxlayout.[Ch]: + * output_docbook.C: XML sanitation: new layout + parameters InnerTag and CommandDepth + 2003-11-13 Martin Vermeer * BufferView_pimpl.C: diff --git a/src/lyxlayout.C b/src/lyxlayout.C index 168997c78d..79c506831c 100644 --- a/src/lyxlayout.C +++ b/src/lyxlayout.C @@ -33,6 +33,7 @@ enum LayoutTags { LT_ALIGNPOSSIBLE, LT_MARGIN, LT_BOTTOMSEP, + LT_COMMANDDEPTH, LT_COPYSTYLE, LT_DEPENDSON, LT_OBSOLETEDBY, @@ -80,7 +81,8 @@ enum LayoutTags { LT_SPACING, LT_TOPSEP, LT_TOCLEVEL, - LT_INTITLE + LT_INNERTAG, + LT_INTITLE // keep this last! }; ///////////////////// @@ -118,6 +120,7 @@ LyXLayout::LyXLayout () pass_thru = false; is_environment = false; toclevel = 0; + commanddepth = 0; } @@ -126,52 +129,54 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) { // This table is sorted alphabetically [asierra 30March96] keyword_item layoutTags[] = { - { "align", LT_ALIGN }, - { "alignpossible", LT_ALIGNPOSSIBLE }, - { "bottomsep", LT_BOTTOMSEP }, - { "copystyle", LT_COPYSTYLE }, - { "dependson", LT_DEPENDSON }, - { "end", LT_END }, - { "endlabelstring", LT_ENDLABELSTRING }, - { "endlabeltype", LT_ENDLABELTYPE }, - { "fill_bottom", LT_FILL_BOTTOM }, - { "fill_top", LT_FILL_TOP }, - { "font", LT_FONT }, - { "freespacing", LT_FREE_SPACING }, - { "intitle", LT_INTITLE }, - { "itemsep", LT_ITEMSEP }, - { "keepempty", LT_KEEPEMPTY }, - { "labelbottomsep", LT_LABEL_BOTTOMSEP }, - { "labelcounter", LT_LABELCOUNTER }, - { "labelfont", LT_LABELFONT }, - { "labelindent", LT_LABELINDENT }, - { "labelsep", LT_LABELSEP }, - { "labelstring", LT_LABELSTRING }, + { "align", LT_ALIGN }, + { "alignpossible", LT_ALIGNPOSSIBLE }, + { "bottomsep", LT_BOTTOMSEP }, + { "commanddepth", LT_COMMANDDEPTH }, + { "copystyle", LT_COPYSTYLE }, + { "dependson", LT_DEPENDSON }, + { "end", LT_END }, + { "endlabelstring", LT_ENDLABELSTRING }, + { "endlabeltype", LT_ENDLABELTYPE }, + { "fill_bottom", LT_FILL_BOTTOM }, + { "fill_top", LT_FILL_TOP }, + { "font", LT_FONT }, + { "freespacing", LT_FREE_SPACING }, + { "innertag", LT_INNERTAG }, + { "intitle", LT_INTITLE }, + { "itemsep", LT_ITEMSEP }, + { "keepempty", LT_KEEPEMPTY }, + { "labelbottomsep", LT_LABEL_BOTTOMSEP }, + { "labelcounter", LT_LABELCOUNTER }, + { "labelfont", LT_LABELFONT }, + { "labelindent", LT_LABELINDENT }, + { "labelsep", LT_LABELSEP }, + { "labelstring", LT_LABELSTRING }, { "labelstringappendix", LT_LABELSTRING_APPENDIX }, - { "labeltype", LT_LABELTYPE }, - { "latexfooter", LT_LATEXFOOTER }, - { "latexheader", LT_LATEXHEADER }, - { "latexname", LT_LATEXNAME }, - { "latexparagraph", LT_LATEXPARAGRAPH }, - { "latexparam", LT_LATEXPARAM }, - { "latextype", LT_LATEXTYPE }, - { "leftmargin", LT_LEFTMARGIN }, - { "margin", LT_MARGIN }, - { "needprotect", LT_NEED_PROTECT }, - { "newline", LT_NEWLINE }, - { "nextnoindent", LT_NEXTNOINDENT }, - { "obsoletedby", LT_OBSOLETEDBY }, - { "optionalargs", LT_OPTARGS }, - { "parindent", LT_PARINDENT }, - { "parsep", LT_PARSEP }, - { "parskip", LT_PARSKIP }, - { "passthru", LT_PASS_THRU }, - { "preamble", LT_PREAMBLE }, - { "rightmargin", LT_RIGHTMARGIN }, - { "spacing", LT_SPACING }, - { "textfont", LT_TEXTFONT }, - { "toclevel", LT_TOCLEVEL }, - { "topsep", LT_TOPSEP } + { "labeltype", LT_LABELTYPE }, + { "latexfooter", LT_LATEXFOOTER }, + { "latexheader", LT_LATEXHEADER }, + { "latexname", LT_LATEXNAME }, + { "latexparagraph", LT_LATEXPARAGRAPH }, + { "latexparam", LT_LATEXPARAM }, + { "latextype", LT_LATEXTYPE }, + { "leftmargin", LT_LEFTMARGIN }, + { "margin", LT_MARGIN }, + { "needprotect", LT_NEED_PROTECT }, + { "newline", LT_NEWLINE }, + { "nextnoindent", LT_NEXTNOINDENT }, + { "obsoletedby", LT_OBSOLETEDBY }, + { "optionalargs", LT_OPTARGS }, + { "parindent", LT_PARINDENT }, + { "parsep", LT_PARSEP }, + { "parskip", LT_PARSKIP }, + { "passthru", LT_PASS_THRU }, + { "preamble", LT_PREAMBLE }, + { "rightmargin", LT_RIGHTMARGIN }, + { "spacing", LT_SPACING }, + { "textfont", LT_TEXTFONT }, + { "toclevel", LT_TOCLEVEL }, + { "topsep", LT_TOPSEP } }; bool error = false; @@ -314,6 +319,11 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) nextnoindent = false; break; + case LT_COMMANDDEPTH: + lexrc.next(); + commanddepth = lexrc.getInteger(); + break; + case LT_LATEXNAME: if (lexrc.next()) latexname_ = lexrc.getString(); @@ -324,6 +334,11 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) latexparam_ = lexrc.getString(); break; + case LT_INNERTAG: + if (lexrc.next()) + innertag_ = lexrc.getString(); + break; + case LT_PREAMBLE: preamble_ = lexrc.getLongString("EndPreamble"); break; diff --git a/src/lyxlayout.h b/src/lyxlayout.h index adc64f7135..772d9aeca4 100644 --- a/src/lyxlayout.h +++ b/src/lyxlayout.h @@ -63,6 +63,8 @@ public: /// std::string const & latexparam() const { return latexparam_; } /// + std::string const & innertag() const { return innertag_; } + /// std::string const & labelstring_appendix() const { return labelstring_appendix_; } @@ -178,6 +180,8 @@ public: int optionalargs; /// Which counter to step std::string counter; + /// Depth of XML command + int commanddepth; private: /// Name of the layout/paragraph environment @@ -205,6 +209,8 @@ private: std::string labelstring_appendix_; /// LaTeX parameter for environment std::string latexparam_; + /// Internal tag to use (e.g., for sect header) + std::string innertag_; /// Macro definitions needed for this layout std::string preamble_; }; diff --git a/src/output_docbook.C b/src/output_docbook.C index cd099f7c7a..047b6a0300 100644 --- a/src/output_docbook.C +++ b/src/output_docbook.C @@ -55,16 +55,13 @@ void docbookParagraphs(Buffer const & buf, Paragraph::depth_type cmd_depth = 0; Paragraph::depth_type depth = 0; // paragraph depth - string item_name; string command_name; ParagraphList::iterator par = const_cast(paragraphs).begin(); ParagraphList::iterator pend = const_cast(paragraphs).end(); for (; par != pend; ++par) { - string sgmlparam; - string c_depth; - string c_params; + string inner_tag; int desc_on = 0; // description mode LyXLayout_ptr const & style = par->layout(); @@ -91,6 +88,7 @@ void docbookParagraphs(Buffer const & buf, } // Write opening SGML tags. + string item_name; switch (style->latextype) { case LATEX_PARAGRAPH: sgml::openTag(os, depth + command_depth, @@ -104,11 +102,9 @@ void docbookParagraphs(Buffer const & buf, command_name = style->latexname(); - sgmlparam = style->latexparam(); - c_params = split(sgmlparam, c_depth,'|'); - - cmd_depth = atoi(c_depth); - + cmd_depth = style->commanddepth; + inner_tag = style->innertag(); + if (command_flag) { if (cmd_depth < command_base) { for (Paragraph::depth_type j = command_depth; @@ -150,9 +146,8 @@ void docbookParagraphs(Buffer const & buf, } sgml::openTag(os, depth + command_depth, false, command_name); - - item_name = c_params.empty() ? "title" : c_params; - sgml::openTag(os, depth + 1 + command_depth, false, item_name); + // Inner tagged header text, e.g. for sectioning: + sgml::openTag(os, depth + 1 + command_depth, false, inner_tag); break; case LATEX_ENVIRONMENT: @@ -208,9 +203,7 @@ void docbookParagraphs(Buffer const & buf, // write closing SGML tags switch (style->latextype) { case LATEX_COMMAND: - end_tag = c_params.empty() ? "title" : c_params; - sgml::closeTag(os, depth + command_depth, - false, end_tag); + sgml::closeTag(os, depth + command_depth, false, inner_tag); break; case LATEX_ENVIRONMENT: if (!style->latexparam().empty()) { -- 2.39.2