(refs #231)Add anchor icon for headlines in Markdown.

This commit is contained in:
takezoe
2014-02-19 03:19:34 +09:00
parent 521d15219c
commit 78073babe4
4 changed files with 38 additions and 2 deletions

View File

@@ -116,8 +116,9 @@ class GitBucketHtmlSerializer(
val tag = s"h${node.getLevel}" val tag = s"h${node.getLevel}"
val headerTextString = printChildrenToString(node) val headerTextString = printChildrenToString(node)
val anchorName = GitBucketHtmlSerializer.generateAnchorName(headerTextString) val anchorName = GitBucketHtmlSerializer.generateAnchorName(headerTextString)
printer.print(s"<$tag>") printer.print(s"""<$tag class="markdown-head">""")
printer.print(s"""<a class="anchor" name="$anchorName" href="#$anchorName"></a>""") printer.print(s"""<a class="markdown-anchor-link" href="#$anchorName"></a>""")
printer.print(s"""<a class="markdown-anchor" name="$anchorName"></a>""")
visitChildren(node) visitChildren(node)
printer.print(s"</$tag>") printer.print(s"</$tag>")
} }

View File

@@ -850,3 +850,18 @@ div.markdown-body table colgroup + tbody tr:first-child td:last-child {
border-top-right-radius: 4px; border-top-right-radius: 4px;
-moz-border-radius-topright: 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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

View File

@@ -11,6 +11,26 @@ $(function(){
$('img[data-toggle=tooltip]').tooltip(); $('img[data-toggle=tooltip]').tooltip();
$('a[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 // syntax highlighting by google-code-prettify
prettyPrint(); prettyPrint();
}); });