');
+ $(this).find('figcaption div.level-left').append($(this).find('figcaption').find('span'));
+ $(this).find('figcaption div.level-right').append($(this).find('figcaption').find('a'));
+ } else {
+ if (clipboard || fold) {
+ $(this).prepend('
');
+ }
+ }
+ });
+
+ if (typeof (ClipboardJS) !== 'undefined' && clipboard) {
$('figure.highlight').each(function () {
var id = 'code-' + Date.now() + (Math.random() * 1000 | 0);
var button = '
';
$(this).attr('id', id);
- if ($(this).find('figcaption').length) {
- $(this).find('figcaption').prepend(button);
- } else {
- $(this).prepend('
' + button + '');
- }
+ $(this).find('figcaption div.level-right').append(button);
});
new ClipboardJS('.highlight .copy');
}
- var fold = IcarusThemeSettings.article.highlight.fold;
- if (fold.trim()) {
+
+ if (fold) {
var button = '
' + (fold === 'unfolded' ? '' : '') + '';
$('figure.highlight').each(function () {
- if ($(this).find('figcaption').length) {
+ // 此处find ">folded" span,如果有自定义code头,并且">folded"进行处理
+ // 使用示例,.md 文件中头行标记">folded"
+ // ```java main.java >folded
+ // import main.java
+ // private static void main(){
+ // // test
+ // int i = 0;
+ // return i;
+ // }
+ // ```
+ if ($(this).find('figcaption').find('span').length > 0) {
+ let spanArr = $(this).find('figcaption').find('span');
+ if (spanArr[0].innerText.indexOf(">folded") > -1) {
+ // 去掉folded
+ spanArr[0].innerText = spanArr[0].innerText.replace(">folded", "")
+ button = '
';
+ $(this).find('figcaption div.level-left').prepend(button);
- // 此处find ">folded" span,如果有自定义code头,并且">folded"进行处理
- // 使用示例,.md 文件中头行标记">folded"
- // ```java main.java >folded
- // import main.java
- // private static void main(){
- // // test
- // int i = 0;
- // return i;
- // }
- // ```
- if ($(this).find('figcaption').find('span').length > 0) {
- let spanArr = $(this).find('figcaption').find('span');
- if (spanArr[0].innerText.indexOf(">folded") > -1) {
- // 去掉folded
- spanArr[0].innerText = spanArr[0].innerText.replace(">folded", "")
- button = '
';
- $(this).find('figcaption').prepend(button);
-
- // 收叠代码块
- toggleFold(this, true);
- return;
- }
+ // 收叠代码块
+ toggleFold(this, true);
+ return;
}
- $(this).find('figcaption').prepend(button);
- } else {
- $(this).prepend('
' + button + '');
}
+ $(this).find('figcaption div.level-left').prepend(button);
toggleFold(this, fold === 'folded');
});