mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
Stardict(html): Add partial support for "audio" tag
This commit is contained in:
parent
3f221041e0
commit
9ae92bf251
|
@ -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> */
|
/* StarDict type 'm' -- Pure meaning. Presented as <pre> */
|
||||||
pre.sdct_m
|
pre.sdct_m
|
||||||
{
|
{
|
||||||
|
|
31
stardict.cc
31
stardict.cc
|
@ -17,6 +17,7 @@
|
||||||
#include "tiff.hh"
|
#include "tiff.hh"
|
||||||
#include "ftshelpers.hh"
|
#include "ftshelpers.hh"
|
||||||
#include "wstring_qt.hh"
|
#include "wstring_qt.hh"
|
||||||
|
#include "audiolink.hh"
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -482,6 +483,36 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
|
||||||
pos += linksReg.cap( 0 ).size();
|
pos += linksReg.cap( 0 ).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle "audio" tags
|
||||||
|
|
||||||
|
QRegExp audioRe( "<\\s*audio\\s*src\\s*=\\s*([\"']+)([^\"']+)([\"'])\\s*>(.*)</audio>", 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() ) + "<span class=\"sdict_h_wav\"><a href=" + href + ">" ).c_str() );
|
||||||
|
newTag += audioRe.cap( 4 );
|
||||||
|
if( audioRe.cap( 4 ).indexOf( "<img " ) < 0 )
|
||||||
|
newTag += " <img src=\"qrcx://localhost/icons/playsound.png\" border=\"0\" alt=\"Play\">";
|
||||||
|
newTag += "</a></span>";
|
||||||
|
|
||||||
|
articleText.replace( pos, audioRe.cap( 0 ).length(), newTag );
|
||||||
|
pos += newTag.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ( articleText.toUtf8().data() );
|
return ( articleText.toUtf8().data() );
|
||||||
}
|
}
|
||||||
case 'm': // Pure meaning, usually means preformatted text
|
case 'm': // Pure meaning, usually means preformatted text
|
||||||
|
|
Loading…
Reference in a new issue