XDXF: A little more handling for <ex> tag (issue #1135)

This commit is contained in:
Abs62 2019-04-01 17:53:36 +03:00
parent ade20fc1bf
commit 052f849be7
2 changed files with 58 additions and 0 deletions

View file

@ -255,6 +255,25 @@ div.xdxf
color: #808080;
}
.xdxf_ex_source:before
{
content:"["
}
.xdxf_ex_source:after
{
content:"]"
}
.xdxf_ex_tran:before
{
content:"— "
}
.xdxf_ex_tran
{
font-style: italic;
}
/* Direct translation */
.xdxf_dtrn
{

View file

@ -145,8 +145,47 @@ string convert( string const & in, DICT_TYPE type, map < string, string > const
while( nodes.size() )
{
QString author, source;
QDomElement el = nodes.at( 0 ).toElement();
author = el.attribute( "author", QString() );
source = el.attribute( "source", QString() );
if( el.hasChildNodes() )
{
QDomNodeList lst = el.childNodes();
for( int i = 0; i < lst.count(); ++i )
{
QDomElement el2 = el.childNodes().at( i ).toElement();
if( el2.tagName().compare( "ex_orig", Qt::CaseInsensitive ) == 0 )
{
el2.setTagName( "span" );
el2.setAttribute( "class", "xdxf_ex_orig" );
}
else if( el2.tagName().compare( "ex_tran", Qt::CaseInsensitive ) == 0 )
{
el2.setTagName( "span" );
el2.setAttribute( "class", "xdxf_ex_tran" );
}
}
}
if( ( !author.isEmpty() || !source.isEmpty() )
&& ( !el.text().isEmpty() || !el.childNodes().isEmpty() ) )
{
QDomElement el2 = dd.createElement( "span" );
el2.setAttribute( "class", "xdxf_ex_source" );
QString text = author;
if( !source.isEmpty() )
{
if( !text.isEmpty() )
text += ", ";
text += source;
}
QDomText txtNode = dd.createTextNode( text );
el2.appendChild( txtNode );
el.appendChild( el2 );
}
if( el.text().isEmpty() && el.childNodes().isEmpty() )
el.appendChild( fakeElement( dd ) );