diff --git a/stardict.cc b/stardict.cc
index d12faef7..961cbeca 100644
--- a/stardict.cc
+++ b/stardict.cc
@@ -445,6 +445,8 @@ private:
string StardictDictionary::handleResource( char type, char const * resource, size_t size )
{
QString text;
+
+ // See "Type identifiers" at http://www.huzheng.org/stardict/StarDictFileFormat
switch( type )
{
case 'x': // Xdxf content
@@ -590,8 +592,24 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
case 'n': // WordNet data. We don't know anything about it.
return "
" + Html::escape( string( resource, size ) ) + "
";
- case 'r': // Resource file list. For now, resources aren't handled.
- return "" + Html::escape( string( resource, size ) ) + "
";
+ case 'r': // Resource file list. For now, only img: is handled.
+ {
+ string result = R"()";
+
+ // Handle img:example.jpg
+ QString imgTemplate( R"(
)" );
+
+ for ( const auto & file : QString::fromUtf8( resource, size ).simplified().split( " " ) ) {
+ if ( file.startsWith( "img:" ) ) {
+ result += imgTemplate.arg( file.right( file.size() - file.indexOf( ":" ) - 1 ) ).toStdString();
+ }
+ else {
+ result += Html::escape( file.toStdString() );
+ }
+ }
+
+ return result + "
";
+ }
case 'W': // An embedded Wav file. Unhandled yet.
return "(an embedded .wav file)
";