mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
XDXF: A little more handling for <ex> tag (issue #1135)
This commit is contained in:
parent
ade20fc1bf
commit
052f849be7
|
@ -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
|
||||
{
|
||||
|
|
39
xdxf2html.cc
39
xdxf2html.cc
|
@ -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 ) );
|
||||
|
||||
|
|
Loading…
Reference in a new issue