mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Fix internal links conversion for saving mode "html only"
This commit is contained in:
parent
5b666afe36
commit
1387a8b5bd
|
@ -3279,6 +3279,19 @@ void MainWindow::on_saveArticle_triggered()
|
|||
QFileInfo fi( fileName );
|
||||
cfg.articleSavePath = QDir::toNativeSeparators( fi.absoluteDir().absolutePath() );
|
||||
|
||||
// Convert internal links
|
||||
|
||||
QRegExp rx3( "href=\"(bword:|gdlookup://localhost/)([^\"]+)\"" );
|
||||
int pos = 0;
|
||||
while ( ( pos = rx3.indexIn( html, pos ) ) != -1 )
|
||||
{
|
||||
QString name = QUrl::fromPercentEncoding( rx3.cap( 2 ).simplified().toLatin1() );
|
||||
name.replace( rxName, "_" );
|
||||
name = QString( "href=\"" ) + QUrl::toPercentEncoding( name ) + ".html\"";
|
||||
html.replace( pos, rx3.cap().length(), name );
|
||||
pos += name.length();
|
||||
}
|
||||
|
||||
if ( complete )
|
||||
{
|
||||
QString folder = fi.absoluteDir().absolutePath() + "/" + fi.baseName() + "_files";
|
||||
|
@ -3308,19 +3321,6 @@ void MainWindow::on_saveArticle_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
// Convert internal links
|
||||
|
||||
QRegExp rx3( "href=\"(bword:|gdlookup://localhost/)([^\"]+)\"" );
|
||||
int pos = 0;
|
||||
while ( ( pos = rx3.indexIn( html, pos ) ) != -1 )
|
||||
{
|
||||
QString name = QUrl::fromPercentEncoding( rx3.cap( 2 ).simplified().toLatin1() );
|
||||
name.replace( rxName, "_" );
|
||||
name = QString( "href=\"" ) + QUrl::toPercentEncoding( name ) + ".html\"";
|
||||
html.replace( pos, rx3.cap().length(), name );
|
||||
pos += name.length();
|
||||
}
|
||||
|
||||
progressDialog->setLabelText( tr("Saving article...") );
|
||||
progressDialog->setRange( 0, maxVal );
|
||||
progressDialog->setValue( 0 );
|
||||
|
|
Loading…
Reference in a new issue