File: prettycode.md

package info (click to toggle)
r-cran-cli 3.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,288 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (225 lines) | stat: -rw-r--r-- 6,481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# reserved [plain]

    Code
      cat(code_highlight("function () { }", list(reserved = "bold")))
    Output
      function () { }
    Code
      cat(code_highlight("if (1) NULL else NULL", list(reserved = "bold")))
    Output
      if (1) NULL else NULL
    Code
      cat(code_highlight("repeat {}", list(reserved = "bold")))
    Output
      repeat {}
    Code
      cat(code_highlight("while (1) {}", list(reserved = "bold")))
    Output
      while (1) {}
    Code
      cat(code_highlight("for (i in x) next", list(reserved = "bold")))
    Output
      for (i in x) next
    Code
      cat(code_highlight("for (i in x) break", list(reserved = "bold")))
    Output
      for (i in x) break

# reserved [ansi]

    Code
      cat(code_highlight("function () { }", list(reserved = "bold")))
    Output
      function () { }
    Code
      cat(code_highlight("if (1) NULL else NULL", list(reserved = "bold")))
    Output
      if (1) NULL else NULL
    Code
      cat(code_highlight("repeat {}", list(reserved = "bold")))
    Output
      repeat {}
    Code
      cat(code_highlight("while (1) {}", list(reserved = "bold")))
    Output
      while (1) {}
    Code
      cat(code_highlight("for (i in x) next", list(reserved = "bold")))
    Output
      for (i in x) next
    Code
      cat(code_highlight("for (i in x) break", list(reserved = "bold")))
    Output
      for (i in x) break

# number [plain]

    Code
      cat(code_highlight("1 + 1.0 + -1 + 2L + Inf", list(number = "bold")))
    Output
      1 + 1.0 + -1 + 2L + Inf
    Code
      cat(code_highlight("NA + NA_real_ + NA_integer_ + NA_character_", list(number = "bold")))
    Output
      NA + NA_real_ + NA_integer_ + NA_character_
    Code
      cat(code_highlight("TRUE + FALSE", list(number = "bold")))
    Output
      TRUE + FALSE

# number [ansi]

    Code
      cat(code_highlight("1 + 1.0 + -1 + 2L + Inf", list(number = "bold")))
    Output
      1 + 1.0 + -1 + 2L + Inf
    Code
      cat(code_highlight("NA + NA_real_ + NA_integer_ + NA_character_", list(number = "bold")))
    Output
      NA + NA_real_ + NA_integer_ + NA_character_
    Code
      cat(code_highlight("TRUE + FALSE", list(number = "bold")))
    Output
      TRUE + FALSE

# null [plain]

    Code
      cat(code_highlight("NULL", list(null = "bold")))
    Output
      NULL

# null [ansi]

    Code
      cat(code_highlight("NULL", list(null = "bold")))
    Output
      NULL

# operator [plain]

    Code
      cat(code_highlight("~ ! 1 - 2 + 3:4 * 5 / 6 ^ 7", list(operator = "bold")))
    Output
      ~ ! 1 - 2 + 3:4 * 5 / 6 ^ 7
    Code
      cat(code_highlight("? 1 %% 2 %+% 2 < 3 & 4 > 5 && 6 == 7 | 8 <= 9 || 10 >= 11",
        list(operator = "bold")))
    Output
      ? 1 %% 2 %+% 2 < 3 & 4 > 5 && 6 == 7 | 8 <= 9 || 10 >= 11
    Code
      cat(code_highlight("a <- 10; 20 -> b; c = 30; a$b; a@b", list(operator = "bold")))
    Output
      a <- 10; 20 -> b; c = 30; a$b; a@b

# operator [ansi]

    Code
      cat(code_highlight("~ ! 1 - 2 + 3:4 * 5 / 6 ^ 7", list(operator = "bold")))
    Output
      ~ ! 1 - 2 + 3:4 * 5 / 6 ^ 7
    Code
      cat(code_highlight("? 1 %% 2 %+% 2 < 3 & 4 > 5 && 6 == 7 | 8 <= 9 || 10 >= 11",
        list(operator = "bold")))
    Output
      ? 1 %% 2 %+% 2 < 3 & 4 > 5 && 6 == 7 | 8 <= 9 || 10 >= 11
    Code
      cat(code_highlight("a <- 10; 20 -> b; c = 30; a$b; a@b", list(operator = "bold")))
    Output
      a <- 10; 20 -> b; c = 30; a$b; a@b

# call [plain]

    Code
      cat(code_highlight("ls(2)", list(call = "bold")))
    Output
      ls(2)

# call [ansi]

    Code
      cat(code_highlight("ls(2)", list(call = "bold")))
    Output
      ls(2)

# string [plain]

    Code
      cat(code_highlight("'s' + \"s\"", list(string = "bold")))
    Output
      's' + "s"

# string [ansi]

    Code
      cat(code_highlight("'s' + \"s\"", list(string = "bold")))
    Output
      's' + "s"

# comment [plain]

    Code
      cat(code_highlight(c("# COM", " ls() ## ANOT"), list(comment = "bold")))
    Output
      # COM  ls() ## ANOT

# comment [ansi]

    Code
      cat(code_highlight(c("# COM", " ls() ## ANOT"), list(comment = "bold")))
    Output
      # COM  ls() ## ANOT

# bracket [plain]

    Code
      cat(code_highlight("foo <- function(x){x}", list(bracket = list("bold"))))
    Output
      foo <- function(x){x}

# bracket [ansi]

    Code
      cat(code_highlight("foo <- function(x){x}", list(bracket = list("bold"))))
    Output
      foo <- function(x){x}

# code_theme_list

    Code
      code_theme_list()
    Output
       [1] "Ambiance"              "Chaos"                 "Chrome"               
       [4] "Clouds"                "Clouds Midnight"       "Cobalt"               
       [7] "Crimson Editor"        "Dawn"                  "Dracula"              
      [10] "Dreamweaver"           "Eclipse"               "Idle Fingers"         
      [13] "Katzenmilch"           "Kr Theme"              "Material"             
      [16] "Merbivore"             "Merbivore Soft"        "Mono Industrial"      
      [19] "Monokai"               "Pastel On Dark"        "Solarized Dark"       
      [22] "Solarized Light"       "Textmate (default)"    "Tomorrow"             
      [25] "Tomorrow Night"        "Tomorrow Night Blue"   "Tomorrow Night Bright"
      [28] "Tomorrow Night 80s"    "Twilight"              "Vibrant Ink"          
      [31] "Xcode"                

# new language features, raw strings [ansi]

    Code
      cat(code_highlight("\"old\" + r\"(\"new\"\"\")\"", list(string = "bold",
        reserved = "italic")))
    Output
      "old" + r"("new""")"

# new language features, pipe [ansi]

    Code
      cat(code_highlight("dir() |> toupper()", list(operator = "bold")))
    Output
      dir() |> toupper()

# new language features, lambda functions [ansi]

    Code
      cat(code_highlight("\\(x) x * 2", list(reserved = "bold")))
    Output
      \(x) x * 2