diff --git a/article-style.css b/article-style.css index 0a081d70..3c8e4612 100644 --- a/article-style.css +++ b/article-style.css @@ -115,6 +115,12 @@ div.sdct_h { } +.sdict_h_wav img +{ + /* Ugly hack since "vertical-align: middle;" looks _terrible_ in Qt4's webkit: */ + vertical-align: -30%; +} + /* StarDict type 'm' -- Pure meaning. Presented as
 */
 pre.sdct_m
 {
diff --git a/stardict.cc b/stardict.cc
index b5abb56a..34c4b15b 100644
--- a/stardict.cc
+++ b/stardict.cc
@@ -17,6 +17,7 @@
 #include "tiff.hh"
 #include "ftshelpers.hh"
 #include "wstring_qt.hh"
+#include "audiolink.hh"
 
 #include 
 #include 
@@ -482,6 +483,36 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
           pos += linksReg.cap( 0 ).size();
       }
 
+      // Handle "audio" tags
+
+      QRegExp audioRe( "<\\s*audio\\s*src\\s*=\\s*([\"']+)([^\"']+)([\"'])\\s*>(.*)", Qt::CaseInsensitive );
+      audioRe.setMinimal( true );
+
+      pos = 0;
+
+      while( pos >= 0 )
+      {
+        pos = audioRe.indexIn( articleText, pos );
+        if( pos < 0 )
+          break;
+
+        QString src = audioRe.cap( 2 );
+        if( src.indexOf( "://" ) >= 0 )
+          pos += audioRe.cap( 0 ).length();
+        else
+        {
+          std::string href = "\"gdau://" + getId() + "/" + src.toUtf8().data() + "\"";
+          QString newTag = QString::fromUtf8( ( addAudioLink( href, getId() ) + "" ).c_str() );
+          newTag += audioRe.cap( 4 );
+          if( audioRe.cap( 4 ).indexOf( "\"Play\"";
+          newTag += "";
+
+          articleText.replace( pos, audioRe.cap( 0 ).length(), newTag );
+          pos += newTag.length();
+        }
+      }
+
       return ( articleText.toUtf8().data() );
     }
     case 'm': // Pure meaning, usually means preformatted text