diff --git a/dsl.cc b/dsl.cc index 6914d697..7f396955 100644 --- a/dsl.cc +++ b/dsl.cc @@ -250,7 +250,7 @@ private: wstring & articleText ); /// Converts DSL language to an Html. - string dslToHtml( wstring const & ); + string dslToHtml( wstring const &, wstring const & headword = wstring() ); // Parts of dslToHtml() string nodeToHtml( ArticleDom::Node const & ); @@ -715,12 +715,12 @@ void DslDictionary::loadArticle( uint32_t address, articleText.clear(); } -string DslDictionary::dslToHtml( wstring const & str ) +string DslDictionary::dslToHtml( wstring const & str, wstring const & headword ) { // Normalize the string wstring normalizedStr = gd::normalize( str ); - ArticleDom dom( normalizedStr ); + ArticleDom dom( normalizedStr, getName(), headword ); optionalPartNom = 0; @@ -1330,7 +1330,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword, articleData.clear(); - ArticleDom dom( gd::normalize( articleText ) ); + ArticleDom dom( gd::normalize( articleText ), getName(), articleHeadword ); articleText.clear(); @@ -1477,7 +1477,7 @@ void DslArticleRequest::run() if( displayedHeadword.size() == 1 && displayedHeadword[0] == '<' ) // Fix special case - "<" header articleText += "<"; // dslToHtml can't handle it correctly. else - articleText += dict.dslToHtml( displayedHeadword ); + articleText += dict.dslToHtml( displayedHeadword, displayedHeadword ); /// After this may be expand button will be inserted @@ -1490,7 +1490,7 @@ void DslArticleRequest::run() articleAfter += " dir=\"rtl\""; articleAfter += ">"; - articleAfter += dict.dslToHtml( articleBody ); + articleAfter += dict.dslToHtml( articleBody, displayedHeadword ); articleAfter += ""; articleAfter += ""; diff --git a/dsl_details.cc b/dsl_details.cc index 551b4cdb..9a4096ee 100644 --- a/dsl_details.cc +++ b/dsl_details.cc @@ -8,6 +8,7 @@ #include "gddebug.hh" #include "ufile.hh" #include "wstring_qt.hh" +#include "utf8.hh" #include #include @@ -62,9 +63,12 @@ static inline bool checkM( wstring const & dest, wstring const & src ) dest[ 0 ] == L'm' && iswdigit( dest[ 1 ] ) ); } -ArticleDom::ArticleDom( wstring const & str ): +ArticleDom::ArticleDom( wstring const & str, string const & dictName, + wstring const & headword_): root( Node::Tag(), wstring(), wstring() ), stringPos( str.c_str() ), - transcriptionCount( 0 ) + transcriptionCount( 0 ), + dictionaryName( dictName ), + headword( headword_ ) { list< Node * > stack; // Currently opened tags @@ -599,8 +603,13 @@ void ArticleDom::closeTag( wstring const & name, else if ( warn ) { - qWarning() << "Warning: no corresponding opening tag for closing tag" << - gd::toQString( name ) << "found."; + if( !dictionaryName.empty() ) + gdWarning( "Warning: no corresponding opening tag for closing tag \"%s\" found in \"%s\", article \"%s\".", + gd::toQString( name ).toUtf8().data(), dictionaryName.c_str(), + gd::toQString( headword ).toUtf8().data() ); + else + gdWarning( "Warning: no corresponding opening tag for closing tag \"%s\" found.", + gd::toQString( name ).toUtf8().data() ); } } diff --git a/dsl_details.hh b/dsl_details.hh index 245a0c0b..f2eff05e 100644 --- a/dsl_details.hh +++ b/dsl_details.hh @@ -62,7 +62,8 @@ struct ArticleDom /// Does the parse at construction. Refer to the 'root' member variable /// afterwards. - ArticleDom( wstring const & ); + ArticleDom( wstring const &, string const & dictName = string(), + wstring const & headword_ = wstring() ); /// Root of DOM's tree Node root; @@ -83,6 +84,10 @@ private: unsigned transcriptionCount; // >0 = inside a [t] tag void nextChar() throw( eot ); + + /// Infomation for diagnostic purposes + string dictionaryName; + wstring headword; }; /// A adapted version of Iconv which takes Dsl encoding and decodes to wchar.