最近在无意间浏览网站时发现一款仿苹果主题的代码块样式非常简洁,代码高亮样式效果如下,个人特别喜欢,于是经过几个夜晚不断摸索修改,现将个人基于Pure-Highlightjs代码高亮插件修改的仿苹果主题样式插件,分享给喜欢码代码的大佬们。
插件说明
- 基于Pure-Highlightjs插件修改
- 仿苹果主题风格样式
- 支持一键复制代码块
- 支持显示代码块语言
-
支持显示代码块行号(某些语言代码高亮后行号显示存在问题) - 支持C,C++ ,PHP, Shell,Java,Python等主流编程语言高亮
使用说明
- 禁用主题自带代码高亮(主题没有自带代码高亮请忽略)
- 后台上传下载好的插件zip格式压缩包并安装启用。
- 后台 “设置”->“Pure-Highlighjs”-> “保存更改”(插件主题默认只保留仿苹果主题样式)。
- 在wordpress后台编辑文章时,经典编辑器点击工具栏<>选择语言插入代码块即可。
使用B2主题注意:使用代码块高亮时隐藏内容会失效。目前还没有找到找到解决办法
示例样式
C语言
#include <stdio.h> int main () { printf("Hello wordpress!\n"); return; }
Python语言
CSS
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
// Code blocks
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
// Inline code
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
// This background color was intended by the author of this theme.
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function,
.token.class-name {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
Shell脚本
# !/bin/sh
if [ $# != 1 ]; then
echo "Usage: $0 [minute/'clean']"
exit;
else
if [ -n "`echo $1|sed 's/[0-9]//g'`" ]; then
echo "Usage: $0 [minute/'clean']"
exit;
else
mtime=$1
fi
fi
net_path=~/work
function check_target_env()
{
if [ "${TARGET_PRODUCT}" = "" ];then
echo "Do not find TARGET_NAME,Please source environment and lunch project"
exit;
else
echo "Current TARGET_PRODUCT: $TARGET_PRODUCT"
echo "Current TARGET_BUILD_VARIANT: $TARGET_BUILD_VARIANT"
:<< !echo "Current TARGET_ARCH: $TARGET_ARCH"
fi
}
function copy_update_files()
{
if [ "${TARGET_ARCH}" == "arm64" ];then
libpath=lib64
else
libpath=lib64
fi
libfile_dir=$(pwd)"/out/target/product/$TARGET_PRODUCT/vendor/$libpath"
find $libfile_dir -mmin -$mtime -type f | while read i
do
echo 'Z:'${i#*hays} >> $net_path/update_files.txt
echo ${i#*$TARGET_PRODUCT} >> $net_path/update_path.txt
done
if [ -f "$net_path/update_files.txt" ];then
sed -i "s/\\//\\\/g" $net_path/update_files.txt
paste -d ' ' $net_path/update_files.txt $net_path/update_path.txt > $net_path/update_files_list.txt
cat $net_path/update_files_list.txt
else
echo No updated files were found $mtime minutes ago
fi
}
function main()
{
rm -rf $net_path/update_files.txt
rm -rf $net_path/update_path.txt
rm -rf $net_path/update_files_list.txt
check_target_env
copy_update_files
echo "Update file list completed."
}
main
没找到下载的地方
尝试一下
66666666666666666666666
666
66666