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