-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Figure Cross Reference | 询问:图片交叉引用 #2507
Comments
Hi @Social-Mean , do you wanna jump images only within one page or cross pages by image anchors ? |
Hi @Koooooo-7 , thank you for your reply. Just within one page is ok for me now, and cross pages is even better :) |
I'm not sure if there were a plugin already made for it or not, you could search it first. Within one page, I suppose you could do the trick if nothing plugins helps for now: i.e.
hook.doneEach(() => {
// search all refer links
const anchors = document.querySelectorAll('a[id]');
anchors.forEach(anchor => {
// add click handler
anchor.addEventListener('click', e => {
// get the refer click target image id
const target = anchor.getAttribute('id');
// search target image id in current page
const selector = `img[id="${target}"]`;
// jump to it
document.querySelector(selector)?.scrollIntoView({
behavior: 'smooth',
});
});
});
}); On cross page, I suppose you may need handle the jump target in higher scope after page change. |
Thank you @Koooooo-7 . A very silly question: where should I put the |
Hi @Social-Mean window.$docsify = {
plugins: [
function (hook, vm) {
hook.doneEach(() => {
...
});
}
],
}; You could refer to the plugin hook doc and the examples. |
Does Docsify support figure cross reference? This need a caption
Figure 1. XXXXXX.
under each figure, and it can be referenced in the body of the text with corresponding hyperlinks to jump to.Docsify 支持图片的交叉引用吗?这需要在每个图片下面添加一个类似
图1 XXXXXX
的图注,并且可以在正文中引用,并有对应的超链接可供跳转。The text was updated successfully, but these errors were encountered: