mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 14:05:52 +01:00
(refs #231)Add anchor icon for headlines in Markdown.
This commit is contained in:
@@ -116,8 +116,9 @@ class GitBucketHtmlSerializer(
|
||||
val tag = s"h${node.getLevel}"
|
||||
val headerTextString = printChildrenToString(node)
|
||||
val anchorName = GitBucketHtmlSerializer.generateAnchorName(headerTextString)
|
||||
printer.print(s"<$tag>")
|
||||
printer.print(s"""<a class="anchor" name="$anchorName" href="#$anchorName"></a>""")
|
||||
printer.print(s"""<$tag class="markdown-head">""")
|
||||
printer.print(s"""<a class="markdown-anchor-link" href="#$anchorName"></a>""")
|
||||
printer.print(s"""<a class="markdown-anchor" name="$anchorName"></a>""")
|
||||
visitChildren(node)
|
||||
printer.print(s"</$tag>")
|
||||
}
|
||||
|
||||
@@ -850,3 +850,18 @@ div.markdown-body table colgroup + tbody tr:first-child td:last-child {
|
||||
border-top-right-radius: 4px;
|
||||
-moz-border-radius-topright: 4px;
|
||||
}
|
||||
|
||||
.markdown-head {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
a.markdown-anchor-link {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: -20px;
|
||||
width: 32px;
|
||||
height: 16px;
|
||||
background-image: url(../images/link.png);
|
||||
background-repeat: no-repeat;
|
||||
display: none;
|
||||
}
|
||||
|
||||
BIN
src/main/webapp/assets/common/images/link.png
Normal file
BIN
src/main/webapp/assets/common/images/link.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 343 B |
@@ -11,6 +11,26 @@ $(function(){
|
||||
$('img[data-toggle=tooltip]').tooltip();
|
||||
$('a[data-toggle=tooltip]').tooltip();
|
||||
|
||||
// anchor icon for markdown
|
||||
$('.markdown-head').mouseenter(function(e){
|
||||
$(e.target).children('a.markdown-anchor-link').show();
|
||||
});
|
||||
$('.markdown-head').mouseleave(function(e){
|
||||
var anchorLink = $(e.target).children('a.markdown-anchor-link');
|
||||
if(anchorLink.data('active') != true){
|
||||
anchorLink.hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('a.markdown-anchor-link').mouseenter(function(e){
|
||||
$(e.target).data('active', true);
|
||||
});
|
||||
|
||||
$('a.markdown-anchor-link').mouseleave(function(e){
|
||||
$(e.target).data('active', false);
|
||||
$(e.target).hide();
|
||||
});
|
||||
|
||||
// syntax highlighting by google-code-prettify
|
||||
prettyPrint();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user