mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 04:17:43 +00:00
DocBook: add DocBookInnerTag and family.
This allows old DocBook documents to be valid when output.
This commit is contained in:
parent
1a054e4571
commit
0bd2978ac9
@ -8,7 +8,7 @@
|
||||
<personname>Article author</personname>
|
||||
</author>
|
||||
<authorgroup>
|
||||
<author>Article author group</author>
|
||||
<author><personname>Article author group</personname></author>
|
||||
</authorgroup>
|
||||
<date>Article date</date>
|
||||
<abstract>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<personname>Book author</personname>
|
||||
</author>
|
||||
<authorgroup>
|
||||
<author>Book author group</author>
|
||||
<author><personname>Book author group</personname></author>
|
||||
</authorgroup>
|
||||
<date>Book date</date>
|
||||
<abstract>
|
||||
|
@ -17,6 +17,8 @@ Style Authorgroup
|
||||
# TODO: missing a DocBookInnerTag to be valid (authorgroup > author > personname).
|
||||
DocBookTag author
|
||||
DocBookTagType paragraph
|
||||
DocBookInnerTag personname
|
||||
DocBookInnerTagType inline
|
||||
DocBookWrapperTag authorgroup
|
||||
DocBookWrapperTagType paragraph
|
||||
End
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This script will update a .layout file to current format
|
||||
|
||||
# The latest layout format is also defined in src/TextClass.cpp
|
||||
currentFormat = 84
|
||||
currentFormat = 85
|
||||
|
||||
|
||||
# Incremented to format 4, 6 April 2007, lasgouttes
|
||||
@ -289,6 +289,9 @@ currentFormat = 84
|
||||
# DocBookItemWrapperTagTagType, DocBookItemTagTagType,
|
||||
# DocBookLabelTag
|
||||
|
||||
# Incremented to format 85, 7 October 2020 by tcuvelier
|
||||
# New tags DocBookInnerTag, DocBookInnerAttr,
|
||||
# DocBookInnerTagType
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
|
||||
@ -538,7 +541,7 @@ def convert(lines, end_format):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if 82 <= format <= 84:
|
||||
if 82 <= format <= 85:
|
||||
# nothing to do.
|
||||
i += 1
|
||||
continue
|
||||
|
@ -107,6 +107,9 @@ enum LayoutTags {
|
||||
LT_DOCBOOKTAG,
|
||||
LT_DOCBOOKATTR,
|
||||
LT_DOCBOOKTAGTYPE,
|
||||
LT_DOCBOOKINNERATTR,
|
||||
LT_DOCBOOKINNERTAG,
|
||||
LT_DOCBOOKINNERTAGTYPE,
|
||||
LT_DOCBOOKININFO,
|
||||
LT_DOCBOOKABSTRACT,
|
||||
LT_DOCBOOKWRAPPERTAG,
|
||||
@ -234,6 +237,9 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass,
|
||||
{ "docbookattr", LT_DOCBOOKATTR },
|
||||
{ "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG },
|
||||
{ "docbookininfo", LT_DOCBOOKININFO },
|
||||
{ "docbookinnerattr", LT_DOCBOOKINNERATTR },
|
||||
{ "docbookinnertag", LT_DOCBOOKINNERTAG },
|
||||
{ "docbookinnertagtype", LT_DOCBOOKINNERTAGTYPE },
|
||||
{ "docbookitemattr", LT_DOCBOOKITEMATTR },
|
||||
{ "docbookiteminnerattr", LT_DOCBOOKITEMINNERATTR },
|
||||
{ "docbookiteminnertag", LT_DOCBOOKITEMINNERTAG },
|
||||
@ -750,6 +756,18 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass,
|
||||
lex >> docbooktagtype_;
|
||||
break;
|
||||
|
||||
case LT_DOCBOOKINNERTAG:
|
||||
lex >> docbookinnertag_;
|
||||
break;
|
||||
|
||||
case LT_DOCBOOKINNERATTR:
|
||||
lex >> docbookinnerattr_;
|
||||
break;
|
||||
|
||||
case LT_DOCBOOKINNERTAGTYPE:
|
||||
lex >> docbookinnertagtype_;
|
||||
break;
|
||||
|
||||
case LT_DOCBOOKFORCEABSTRACTTAG:
|
||||
lex >> docbookforceabstracttag_;
|
||||
break;
|
||||
@ -1638,6 +1656,12 @@ void Layout::write(ostream & os) const
|
||||
os << "\tDocBookAttr \"" << docbookattr_ << "\"\n";
|
||||
if(!docbooktagtype_.empty())
|
||||
os << "\tDocBookTagType " << docbooktagtype_ << '\n';
|
||||
if(!docbookinnertag_.empty())
|
||||
os << "\tDocBookInnerTag " << docbookinnertag_ << '\n';
|
||||
if(!docbookinnerattr_.empty())
|
||||
os << "\tDocBookInnerAttr \"" << docbookinnerattr_ << "\"\n";
|
||||
if(!docbookinnertagtype_.empty())
|
||||
os << "\tDocBookInnerTagType " << docbookinnertagtype_ << '\n';
|
||||
if(!docbookininfo_.empty())
|
||||
os << "\tDocBookInInfo " << docbookininfo_ << '\n';
|
||||
os << "\tDocBookAbstract " << docbookabstract_ << '\n';
|
||||
@ -1857,6 +1881,28 @@ string const & Layout::docbooktagtype() const
|
||||
}
|
||||
|
||||
|
||||
string const & Layout::docbookinnertag() const
|
||||
{
|
||||
if (docbookinnertag_.empty())
|
||||
docbookinnertag_ = "NONE";
|
||||
return docbookinnertag_;
|
||||
}
|
||||
|
||||
|
||||
string const & Layout::docbookinnerattr() const
|
||||
{
|
||||
return docbookinnerattr_;
|
||||
}
|
||||
|
||||
|
||||
string const & Layout::docbookinnertagtype() const
|
||||
{
|
||||
if (!isValidTagType(docbookinnertagtype_))
|
||||
docbookinnertagtype_ = "block";
|
||||
return docbookinnertagtype_;
|
||||
}
|
||||
|
||||
|
||||
string const & Layout::docbookininfo() const
|
||||
{
|
||||
// Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never".
|
||||
|
12
src/Layout.h
12
src/Layout.h
@ -199,6 +199,12 @@ public:
|
||||
///
|
||||
std::string const & docbooktagtype() const;
|
||||
///
|
||||
std::string const & docbookinnertag() const;
|
||||
///
|
||||
std::string const & docbookinnerattr() const;
|
||||
///
|
||||
std::string const & docbookinnertagtype() const;
|
||||
///
|
||||
std::string const & docbookininfo() const;
|
||||
///
|
||||
bool docbookabstract() const { return docbookabstract_; }
|
||||
@ -509,6 +515,12 @@ private:
|
||||
mutable std::string docbookattr_;
|
||||
/// DocBook tag type corresponding to this layout (block, paragraph, or inline; default: block).
|
||||
mutable std::string docbooktagtype_;
|
||||
/// DocBook inner tag corresponding to this layout.
|
||||
mutable std::string docbookinnertag_;
|
||||
/// Roles to add to docbookinnertag_, if any (default: none).
|
||||
mutable std::string docbookinnerattr_;
|
||||
/// DocBook inner-tag type corresponding to this layout (block, paragraph, or inline; default: block).
|
||||
mutable std::string docbookinnertagtype_;
|
||||
/// DocBook tag corresponding to this item (mainly for lists).
|
||||
mutable std::string docbookitemtag_;
|
||||
/// Roles to add to docbookitemtag_, if any (default: none).
|
||||
|
@ -62,7 +62,7 @@ namespace lyx {
|
||||
// You should also run the development/tools/updatelayouts.py script,
|
||||
// to update the format of all of our layout files.
|
||||
//
|
||||
int const LAYOUT_FORMAT = 84; // tcuvelier: DocBook*TagType.
|
||||
int const LAYOUT_FORMAT = 85; // tcuvelier: DocBookInnerTag.
|
||||
|
||||
|
||||
// Layout format for the current lyx file format. Controls which format is
|
||||
|
@ -309,10 +309,12 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
|
||||
const string & tag = lay.docbooktag();
|
||||
if (tag != "NONE") {
|
||||
auto xmltag = xml::ParTag(tag, lay.docbookattr());
|
||||
if (!xs.isTagOpen(xmltag, 1)) // Don't nest a paragraph directly in a paragraph.
|
||||
if (!xs.isTagOpen(xmltag, 1)) { // Don't nest a paragraph directly in a paragraph.
|
||||
// TODO: required or not?
|
||||
// TODO: avoid creating a ParTag object just for this query...
|
||||
openTag(xs, lay.docbooktag(), lay.docbookattr(), lay.docbooktagtype());
|
||||
openTag(xs, lay.docbookinnertag(), lay.docbookinnerattr(), lay.docbookinnertagtype());
|
||||
}
|
||||
}
|
||||
|
||||
openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype());
|
||||
@ -342,6 +344,7 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
|
||||
// Main logic.
|
||||
closeTag(xs, lay.docbookiteminnertag(), lay.docbookiteminnertagtype());
|
||||
closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype());
|
||||
closeTag(xs, lay.docbookinnertag(), lay.docbookinnertagtype());
|
||||
closeTag(xs, lay.docbooktag(), lay.docbooktagtype());
|
||||
if (closeWrapper)
|
||||
closeTag(xs, lay.docbookwrappertag(), lay.docbookwrappertagtype());
|
||||
|
Loading…
Reference in New Issue
Block a user