mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Convert internal links while saving article to html
This commit is contained in:
parent
1d60f0ada1
commit
5b666afe36
|
@ -3231,10 +3231,11 @@ void MainWindow::on_saveArticle_triggered()
|
|||
{
|
||||
ArticleView *view = getCurrentArticleView();
|
||||
|
||||
QString fileName = view->getTitle();
|
||||
QString fileName = view->getTitle().simplified();
|
||||
|
||||
// Replace reserved filename characters
|
||||
fileName.replace( QRegExp( "[/\\\\\\?\\*:\\|<>]" ), "_" );
|
||||
QRegExp rxName( "[/\\\\\\?\\*:\\|<>]" );
|
||||
fileName.replace( rxName, "_" );
|
||||
|
||||
fileName += ".html";
|
||||
QString savePath;
|
||||
|
@ -3307,6 +3308,19 @@ 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