highlight.styl 3.2 KB
Newer Older
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
1 2 3
@require './theme.styl'
@require './diff.styl'

4
languages = 'js' 'javascript' 'python' 'ruby' 'xml' 'html' 'css' 'php' 'sql' 'coffeescript' 'java' 'bash' 'markdown' 'kotlin' 'c' 'c\+\+' 'c#' 'go' 'golang' 'less' 'sass' 'scss' 'stylus' 'styl' 'typescript' 'ts' 'yml' 'yaml' 'matlab' 'objectivec' 'makefile' 'scala' 'gradle' 'swift' 'rust' 'lua' 'lisp' 'fortran' 'dart' 'perl'
5
$wordWrap = hexo-config('code_word_wrap')
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
6

7
for lang in languages
8 9 10
  .highlight{'.' + lang}
    figcaption
      span
11
        &:first-child::before
12 13 14 15 16
          content: lang
          margin: 0 .6rem
          color: alpha($highlight-header-color, .5)

.highlight
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
17
  overflow: auto
18 19
  position: relative
  margin: .5rem 0 1rem
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
20 21 22 23 24 25 26 27 28 29
  min-width: 100%
  line-height: $line-height-code-block
  color: $highlight-color
  background-color: $highlight-background

  pre,
  code
    font-family: $code-font-family

  pre
30
    margin: 0
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
31

32 33 34
    if ($wordWrap)
      white-space: pre-wrap
      counter-reset: line
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
35

36 37
  td
    border: 0
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
38

39 40 41 42 43 44
  figcaption
    overflow: hidden
    padding: .1rem 0
    width: 100%
    color: $highlight-header-color
    background-color: $highlight-header-bg-color
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
45

46
    span
47 48 49
      &:first-child
        float: left
        color: $highlight-header-color
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
50

51 52 53 54
    span
      &:nth-child(2)
        float: right
        margin-right: 2rem
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
55

56 57 58
  figcaption.custom
    padding: .1rem 0
    min-height: 1.5rem
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
59

60 61 62
    .custom-lang
      float: left
      margin: 0 .6rem
63
      color: alpha($highlight-header-color, .5)
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
64

65 66 67
  .gutter,
  .code
    padding: .4rem .5rem
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
68

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
  .gutter
    width: 1rem
    background-color: $highlight-gutter-bg-color

    if ($wordWrap)
      display: none

    pre
      text-align: right
      color: $highlight-gutter-color
      background-color: inherit

  if ($wordWrap)
    .line
      &::before
        content: counter(line)
        display: inline-block
        margin: 0 1rem 0 0
        width: 1rem
        text-align: right
        color: $highlight-gutter-color
        counter-increment: line
EvanOne(文一)'s avatar
EvanOne(文一) 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167

  pre
    .variable,
    .attribute
      color: $highlight-red

    .number,
    .preprocessor,
    .literal,
    .params,
    .constant,
    .number,
    .command
      color: $highlight-orange

    .built_in
      color: $highlight-yellow

    .special,
    .formula,
    .class,
    .string,
    .value,
    .inheritance,
    .header,
    .regexp,
    .tag
      color: $highlight-green

    .keyword,
    .title
      color: $highlight-aqua

    .function,
    .title
      color: $highlight-blue

    .comment
      color: $highlight-comment

  .ruby .constant,
  .xml .tag .title,
  .xml .pi,
  .xml .doctype,
  .html .doctype,
  .css .id,
  .tag .name,
  .css .class,
  .css .pseudo
    color: $highlight-red

  .ruby .class .title,
  .css .rules .attribute,
  .ruby .symbol,
  .xml .cdata
    color: $highlight-green

  .css .hexcolor,
  .tag .string
    color: $highlight-aqua

  .python .decorator,
  .python .title,
  .ruby .function .title,
  .ruby .title .keyword,
  .perl .sub,
  .javascript .title,
  .js .title,
  .coffeescript .title
    color: $highlight-blue

  .tag .attr,
  .javascript .keyword,
  .javascript .function,
  .js .keyword,
  .js .function
    color: $highlight-purple
168 169 170 171 172 173

  .diff .addition
    background-color: $highlight-addition

  .diff .deletion
    background-color: $highlight-deletion