Convert internal links while saving article to html

This commit is contained in:
Abs62 2015-07-02 18:16:14 +03:00
parent 1d60f0ada1
commit 5b666afe36

View file

@ -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 );