mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
change Marked's renderer to be identical with Hoedown
Change the style of the header to align with what Hoedown does (use id as anchor). Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
d1a3a9c386
commit
fe3d16ba3b
@ -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:
|
||||
var scrollToAnchor = function(anchor) {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
new QWebChannel(qt.webChannelTransport,
|
||||
|
@ -30,11 +30,8 @@
|
||||
anchor: escapedText,
|
||||
title: text
|
||||
});
|
||||
return '<h' + level + '><a name="' +
|
||||
escapedText +
|
||||
'" class="anchor" href="#' +
|
||||
escapedText +
|
||||
'"><span class="header-link"></span></a>' +
|
||||
return '<h' + level + ' id="' +
|
||||
escapedText + '">' +
|
||||
text + '</h' + level + '>';
|
||||
};
|
||||
|
||||
@ -148,23 +145,8 @@
|
||||
handleToc(needToc);
|
||||
};
|
||||
|
||||
// Type = 0, Hoedown, getElementById;
|
||||
// Type = 1, Marked, getElementsByTagName;
|
||||
var scrollToAnchor = function(anchor, type) {
|
||||
switch (type) {
|
||||
case 0:
|
||||
var scrollToAnchor = function(anchor) {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
new QWebChannel(qt.webChannelTransport,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user