diff --git a/src/resources/pre_template.html b/src/resources/pre_template.html
index 05ca6abe..f3a69794 100644
--- a/src/resources/pre_template.html
+++ b/src/resources/pre_template.html
@@ -16,23 +16,8 @@
'use strict';
var content;
- // Type = 0, Hoedown, getElementById;
- // Type = 1, Marked, getElementsByTagName;
- var scrollToAnchor = function(anchor, type) {
- switch (type) {
- case 0:
- document.getElementById(anchor).scrollIntoView();
- break;
- case 1:
- var eles = document.getElementsByTagName('a');
- for (var i = 0; i < eles.length; ++i) {
- if (eles[i].name == anchor) {
- eles[i].scrollIntoView();
- break;
- }
- }
- break;
- }
+ var scrollToAnchor = function(anchor) {
+ document.getElementById(anchor).scrollIntoView();
};
new QWebChannel(qt.webChannelTransport,
diff --git a/src/resources/template.html b/src/resources/template.html
index 4e386364..942ed8a8 100644
--- a/src/resources/template.html
+++ b/src/resources/template.html
@@ -30,11 +30,8 @@
anchor: escapedText,
title: text
});
- return '' +
+ return '' +
text + '';
};
@@ -148,23 +145,8 @@
handleToc(needToc);
};
- // Type = 0, Hoedown, getElementById;
- // Type = 1, Marked, getElementsByTagName;
- var scrollToAnchor = function(anchor, type) {
- switch (type) {
- case 0:
- document.getElementById(anchor).scrollIntoView();
- break;
- case 1:
- var eles = document.getElementsByTagName('a');
- for (var i = 0; i < eles.length; ++i) {
- if (eles[i].name == anchor) {
- eles[i].scrollIntoView();
- break;
- }
- }
- break;
- }
+ var scrollToAnchor = function(anchor) {
+ document.getElementById(anchor).scrollIntoView();
};
new QWebChannel(qt.webChannelTransport,
diff --git a/src/vdocument.cpp b/src/vdocument.cpp
index dd78343d..9e3c0f8f 100644
--- a/src/vdocument.cpp
+++ b/src/vdocument.cpp
@@ -39,7 +39,7 @@ QString VDocument::getToc()
return m_toc;
}
-void VDocument::scrollToAnchor(const QString &anchor, int type)
+void VDocument::scrollToAnchor(const QString &anchor)
{
- emit requestScrollToAnchor(anchor, type);
+ emit requestScrollToAnchor(anchor);
}
diff --git a/src/vdocument.h b/src/vdocument.h
index 1312beee..88982a23 100644
--- a/src/vdocument.h
+++ b/src/vdocument.h
@@ -16,7 +16,7 @@ public:
void setText(const QString &text);
QString getText();
QString getToc();
- void scrollToAnchor(const QString &anchor, int type);
+ void scrollToAnchor(const QString &anchor);
public slots:
// Will be called in the HTML side
@@ -25,7 +25,7 @@ public slots:
signals:
void textChanged(const QString &text);
void tocChanged(const QString &toc);
- void requestScrollToAnchor(const QString &anchor, int type);
+ void requestScrollToAnchor(const QString &anchor);
private:
QString m_text;
diff --git a/src/vedittab.cpp b/src/vedittab.cpp
index 6b79602e..37f04fdf 100644
--- a/src/vedittab.cpp
+++ b/src/vedittab.cpp
@@ -345,7 +345,7 @@ void VEditTab::scrollToAnchor(const VAnchor &anchor)
}
} else {
if (!anchor.anchor.isEmpty()) {
- document.scrollToAnchor(anchor.anchor.mid(1), mdConverterType);
+ document.scrollToAnchor(anchor.anchor.mid(1));
}
}
}