summaryrefslogtreecommitdiffstats
path: root/src/translators/risimporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/translators/risimporter.cpp')
-rw-r--r--src/translators/risimporter.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/translators/risimporter.cpp b/src/translators/risimporter.cpp
index 735368c..0158708 100644
--- a/src/translators/risimporter.cpp
+++ b/src/translators/risimporter.cpp
@@ -188,7 +188,7 @@ void RISImporter::readURL(const KURL& url_, int n, const TQDict<Data::Field>& ri
// technically, the spec requires a space immediately after the hyphen
// however, at least one website (Springer) outputs RIS with no space after the final "ER -"
// so just strip the white space later
- // also be gracious and allow only any amount of space before hyphen
+ // also be gracious and allow any amount of space before hyphen
TQRegExp rx(TQString::fromLatin1("^(\\w\\w)\\s+-(.*)$"));
TQString currLine, nextLine;
for(currLine = t.readLine(); !m_cancelled && !currLine.isNull(); currLine = nextLine, j += currLine.length()) {
@@ -312,4 +312,25 @@ void RISImporter::slotCancel() {
m_cancelled = true;
}
+bool RISImporter::maybeRIS(const KURL& url_) {
+ TQString text = FileHandler::readTextFile(url_, true /*quiet*/);
+ if(text.isEmpty()) {
+ return false;
+ }
+
+ // bare bones check, strip white space at beginning
+ // and then first text line must be valid RIS
+ TQTextIStream t(&text);
+
+ TQRegExp rx(TQString::fromLatin1("^(\\w\\w)\\s+-(.*)$"));
+ TQString currLine;
+ for(currLine = t.readLine(); !currLine.isNull(); currLine = t.readLine()) {
+ if(currLine.stripWhiteSpace().isEmpty()) {
+ continue;
+ }
+ break;
+ }
+ return rx.exactMatch(currLine);
+}
+
#include "risimporter.moc"