diff --git a/src/js/meditor/index.js b/src/js/meditor/index.js index 1342312..25236dd 100644 --- a/src/js/meditor/index.js +++ b/src/js/meditor/index.js @@ -108,8 +108,8 @@ const ELEMS = { strong: function(str, attr, inner) { return (inner && '**' + inner + '**') || '' }, - pre: function(str, attr, inner) { + inner = inner.replace(/<[/]?code>/g, '') return '\n\n```\n' + inner + '\n```\n' }, code: function(str, attr, inner) { @@ -174,9 +174,6 @@ function html2md(str) { } } else { str = str.replace(exp, cb) - if (i === 'pre') { - str = str.replace(/<[/]?code>/g, '') - } } // 对另外3种同类标签做一次处理 diff --git a/src/js/prism/base.js b/src/js/prism/base.js index c9c73b7..fd6c6a6 100644 --- a/src/js/prism/base.js +++ b/src/js/prism/base.js @@ -777,10 +777,11 @@ Prism.languages.js = Prism.languages.javascript inside: insideString } ], + params: / (-[\w]+)/, variable: insideString.variable, // Originally based on http://ss64.com/bash/ function: { - pattern: /(^|\s|;|\||&)(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|\s|;|\||&)/, + pattern: /(^|\s|;|\||&)(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|up|update|upgrade|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|\s|;|\||&)/, lookbehind: true }, keyword: { @@ -859,7 +860,7 @@ Prism.languages.yaml = { important: /[&*][\w]+/, punctuation: /---|[:[\]{}\-,|>?]|\.\.\./ } -Prism.languages.other = {} +Prism.languages.other = Prism.languages.clike window.Prism = Prism export default Prism diff --git a/src/js/prism/highlight.scss b/src/js/prism/highlight.scss index 7d0bf91..ef8f98f 100644 --- a/src/js/prism/highlight.scss +++ b/src/js/prism/highlight.scss @@ -6,44 +6,44 @@ * */ +@import 'var.scss'; + /*代码块*/ -.do-ui-blockcode {position: relative;border: 1px solid #ddd;margin: 15px 0;padding: 8px 0;line-height: 1.5;background: #fafafa; +.do-ui-blockcode {position: relative;margin: 15px 0;padding: 8px 0;line-height: 1.5;border-radius:3px;background: nth($cp, 2); + + /*语法高亮*/ + .lang {position: relative;display: block;padding: 0 8px;color: #383a42;word-wrap: break-word;white-space: pre-wrap;font-family: Courier; + + .c-comment{color: #8e908c;font-style:italic;} + .c-smartyx {color: #607d8b;} + .c-important {color: #f5871f;font-style:italic;} + .c-punctuation {color: #986756;} + .c-regex {color: #c82829;} + + .c-boolean, + .c-number,.c-params {color: #f5871f;} + .c-function {color:#009688;} + + .c-class-name, + .c-build-in {color:#3aa9f3;} + + .c-class-name, + .c-build-in {font-style:italic;font-weight:bold;} + + .c-attr-name, + .c-property {color: #c79f0f;font-weight:bold;} - /*语法高亮*/ - .lang {position: relative;display: block;padding: 0 8px;color: #383a42;word-wrap: break-word;white-space: pre-wrap;font-family: Courier; + .c-string, + .c-attr-value {color: #5ab302;} - .c-comment{color: #8e908c;font-style:italic;} - .c-smartyx {color: #607d8b;} - .c-important {color: #f5871f;font-style:italic;} - .c-punctuation {color: #986756;} - .c-regex {color: #c82829;} + .c-tag, + .c-keyword, + .c-selector, + .c-operator {color: #d81406;} - .c-boolean, - .c-number {color: #f5871f;} - .c-function {color:#009688;} - - .c-class-name, - .c-build-in {color:#3aa9f3;} - - .c-class-name, - .c-build-in {font-style:italic;font-weight:bold;} - - .c-attr-name, - .c-property {color: #c79f0f;font-weight:bold;} - - .c-property {font-style:italic;} - - .c-string, - .c-attr-value {color: #5ab302;} - - .c-tag, - .c-keyword, - .c-selector, - .c-operator {color: #d81406;} - - .c-keyword {font-style:italic;} - } + .c-keyword,.c-params,.c-property {font-style:italic;} + } } /*行内代码*/ -.do-ui-inlinecode {margin:0 2px;padding:0 5px;color:#d14;border:1px solid #ddd;border-radius:3px;} \ No newline at end of file +.do-ui-inlinecode {display:inline-block;margin:0 2px;padding:0 5px;line-height: 1.5;color:#d14;background: nth($cp, 2);border-radius:3px;} \ No newline at end of file