Skip to content

Commit 341b994

Browse files
committed
Updated project and examples to swift 4, updated highlight.js to 9.12.0
1 parent 3c74f9a commit 341b994

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+337
-71
lines changed

Example/Highlightr.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@
673673
PRODUCT_BUNDLE_IDENTIFIER = "com.raspu.Highlightr-OSX-Example";
674674
PRODUCT_NAME = "$(TARGET_NAME)";
675675
SDKROOT = macosx;
676-
SWIFT_VERSION = 3.0;
676+
SWIFT_VERSION = 4.0;
677677
};
678678
name = Debug;
679679
};
@@ -691,7 +691,7 @@
691691
PRODUCT_BUNDLE_IDENTIFIER = "com.raspu.Highlightr-OSX-Example";
692692
PRODUCT_NAME = "$(TARGET_NAME)";
693693
SDKROOT = macosx;
694-
SWIFT_VERSION = 3.0;
694+
SWIFT_VERSION = 4.0;
695695
};
696696
name = Release;
697697
};

Example/Highlightr/SampleCode.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class SampleCode: UIViewController
6969

7070
@IBAction func pickLanguage(_ sender: AnyObject)
7171
{
72-
let languages = highlightr.supportedLanguages()
72+
let languages = highlightr.supportedLanguages().sorted()
7373
let indexOrNil = languages.index(of: languageName.text!.lowercased())
7474
let index = (indexOrNil == nil) ? 0 : indexOrNil!
7575

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
#Если Клиент Тогда
2-
Перем СимвольныйКодКаталога = "ля-ля-ля"; //комментарий
3-
Функция Сообщить(Знач ТекстСообщения, ТекстСообщения2) Экспорт //комментарий к функции
4-
x=ТекстСообщения+ТекстСообщения2+"
5-
|строка1
6-
|строка2
7-
|строка3";
8-
КонецФункции
9-
#КонецЕсли
10-
11-
// Процедура ПриНачалеРаботыСистемы
12-
//
13-
Процедура ПриНачалеРаботыСистемы()
14-
Обработки.Помощник.ПолучитьФорму("Форма").Открыть();
15-
d = '21.01.2008'
16-
КонецПроцедуры
1+
#ЗагрузитьИзФайла ext_module.txt // директива 7.7
2+
#Если Клиент ИЛИ НаКлиенте Тогда // инструкции препроцессора
3+
&НаКлиентеНаСервереБезКонтекста // директивы компиляции
4+
Функция ТолстыйКлиентОбычноеПриложение(Знач Параметр1 = Неопределено, // комментарий
5+
Параметр2 = "", ПараметрN = 123.45, ПарамNN) Экспорт // еще комментарий
6+
Попытка
7+
Результат_Булевы_Значения = Новый Структура("П1, П2", Истина, Ложь, NULL, Неопределено);
8+
Перейти ~МеткаGOTO; // комментарий
9+
РезультатТаблицаДат = Новый ТаблицаЗначений;
10+
РезультатТаблицаДат.Колонки.Добавить("Колонка1",
11+
Новый ОписаниеТипов("Дата", , ,
12+
Новый КвалификаторыДаты(ЧастиДаты.ДатаВремя));
13+
НС = РезультатТаблицаДат.Добавить(); НС["Колонка1"] = '20170101120000');
14+
Исключение
15+
ОписаниеОшибки = ОписаниеОшибки(); // встроенная функция
16+
Масс = Новый Массив; // встроенный тип
17+
Для Каждого Значение Из Масс Цикл
18+
Сообщить(Значение + Символы.ПС + "
19+
|продолжение строки"); // продолжение многострочной строки
20+
Продолжить; Прервать;
21+
КонецЦикла;
22+
СправочникСсылка = Справочники.Языки.НайтиПоНаименованию("ru"); // встроенные типы
23+
СправочникОбъект = СправочникСсылка.ПолучитьОбъект();
24+
ПеречислениеСсылка = Перечисления.ВидыМодификацииДанных.Изменен;
25+
ВызватьИсключение ОписаниеОшибки;
26+
КонецПопытки;
27+
~МеткаGOTO: // еще комментарий
28+
ВД = ВидДвиженияБухгалтерии.Дебет;
29+
КонецФункции // ТолстыйКлиентОбычноеПриложение()
30+
#КонецЕсли
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Person
2-
def initialize(@name)
2+
def initialize(@name : String)
33
end
44

55
def greet
@@ -11,13 +11,19 @@ class Employee < Person
1111
end
1212

1313
employee = Employee.new "John"
14-
employee.greet #=> "Hi, I'm John"
15-
employee.is_a?(Person) #=> true
14+
employee.greet # => "Hi, I'm John"
15+
employee.is_a?(Person) # => true
1616

1717
@[Link("m")]
1818
lib C
1919
# In C: double cos(double x)
2020
fun cos(value : Float64) : Float64
2121
end
2222

23-
C.cos(1.5_f64) #=> 0.0707372
23+
C.cos(1.5_f64) # => 0.0707372
24+
25+
s = uninitialized String
26+
s = <<-'STR'
27+
\hello\world
28+
\hello\world
29+
STR
+11-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
using System;
1+
using System.IO.Compression;
22

33
#pragma warning disable 414, 3021
44

5-
/// <summary>Main task</summary>
6-
async Task<int, int> AccessTheWebAsync()
5+
namespace MyApplication
76
{
8-
Console.WriteLine("Hello, World!");
9-
string urlContents = await getStringTask;
10-
return urlContents.Length;
7+
[Obsolete("...")]
8+
class Program : IInterface
9+
{
10+
public static List<int> JustDoIt(int count)
11+
{
12+
Console.WriteLine($"Hello {Name}!");
13+
return new List<int>(new int[] { 1, 2, 3 })
14+
}
15+
}
1116
}

Example/Highlightr/Samples/dockerfile/default.txt

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ENV foo /bar
77
WORKDIR ${foo} # WORKDIR /bar
88
ADD . $foo # ADD . /bar
99
COPY \$foo /quux # COPY $foo /quux
10+
ARG VAR=FOO
1011

1112
RUN apt-get update && apt-get install -y software-properties-common\
1213
zsh curl wget git htop\
@@ -30,6 +31,7 @@ ADD hom?.txt /mydir/ # ? is replaced with any single character
3031

3132
COPY hom* /mydir/ # adds all files starting with "hom"
3233
COPY hom?.txt /mydir/ # ? is replaced with any single character
34+
COPY --from=foo / .
3335

3436
ENTRYPOINT ["executable", "param1", "param2"]
3537
ENTRYPOINT command param1 param2
@@ -46,3 +48,9 @@ that label-values can span multiple lines."
4648
WORKDIR /path/to/workdir
4749

4850
ONBUILD ADD . /app/src
51+
52+
STOPSIGNAL SIGKILL
53+
54+
HEALTHCHECK --retries=3 cat /health
55+
56+
SHELL ["/bin/bash", "-c"]
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env hy
2+
3+
(import os.path)
4+
5+
(import hy.compiler)
6+
(import hy.core)
7+
8+
9+
;; absolute path for Hy core
10+
(setv *core-path* (os.path.dirname hy.core.--file--))
11+
12+
13+
(defn collect-macros [collected-names opened-file]
14+
(while True
15+
(try
16+
(let [data (read opened-file)]
17+
(if (and (in (first data)
18+
'(defmacro defmacro/g! defn))
19+
(not (.startswith (second data) "_")))
20+
(.add collected-names (second data))))
21+
(except [e EOFError] (break)))))
22+
23+
24+
(defmacro core-file [filename]
25+
`(open (os.path.join *core-path* ~filename)))
26+
27+
28+
(defmacro contrib-file [filename]
29+
`(open (os.path.join *core-path* ".." "contrib" ~filename)))
30+
31+
32+
(defn collect-core-names []
33+
(doto (set)
34+
(.update hy.core.language.*exports*)
35+
(.update hy.core.shadow.*exports*)
36+
(collect-macros (core-file "macros.hy"))
37+
(collect-macros (core-file "bootstrap.hy"))))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
jms-queue add --queue-address=myQueue --entries=queue/myQueue
2+
3+
deploy /path/to/file.war
4+
5+
/system-property=prop1:add(value=value1)
6+
7+
8+
9+
/extension=org.jboss.as.modcluster:add
10+
11+
./foo=bar:remove
12+
13+
/subsystem=security/security-domain=demo-realm/authentication=classic:add
14+
15+
/subsystem=security/security-domain=demo-realm/authentication=classic/login-module=UsersRoles:add( \
16+
code=UsersRoles, \
17+
flag=required, \
18+
module-options= { \
19+
usersProperties=auth/demo-users.properties, \
20+
rolesProperties =auth/demo-roles.properties, \
21+
hashAlgorithm= MD5, \
22+
hashCharset="UTF-8" \
23+
} \
24+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
julia> function foo(x) x + 1 end
2+
foo (generic function with 1 method)
3+
4+
julia> foo(42)
5+
43
6+
7+
julia> foo(42) === 43.
8+
false
9+
10+
11+
Here we match all three lines of code:
12+
13+
julia> function foo(x::Float64)
14+
42. - x
15+
end
16+
foo (generic function with 2 methods)
17+
18+
julia> for x in Any[1, 2, 3.4]
19+
println("foo($x) = $(foo(x))")
20+
end
21+
foo(1) = 2
22+
foo(2) = 3
23+
foo(3.4) = 38.6
24+
25+
26+
... unless it is not properly indented:
27+
28+
julia> function foo(x)
29+
x + 1
30+
end
31+
32+
33+
Ordinary Julia code does not get highlighted:
34+
35+
Pkg.add("Combinatorics")
36+
abstract type Foo end

Example/Highlightr/Samples/julia/default.txt

+61-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,60 @@
1-
using Profile
1+
### Types
22

3-
# type definition
4-
immutable Point{T<:FloatingPoint}
3+
# Old-style definitions
4+
5+
immutable Point{T<:AbstractFloat}
56
index::Int
67
x::T
78
y::T
89
end
910

11+
abstract A
12+
13+
type B <: A end
14+
15+
typealias P Point{Float16}
16+
17+
# New-style definitions
18+
19+
struct Plus
20+
f::typeof(+)
21+
end
22+
23+
mutable struct Mut
24+
mutable::A # mutable should not be highlighted (not followed by struct)
25+
primitive::B # primitive should not be highlighted (not followed by type)
26+
end
27+
28+
primitive type Prim 8 end
29+
30+
abstract type Abstr end
31+
32+
### Modules
33+
34+
module M
35+
36+
using X
37+
import Y
38+
importall Z
39+
40+
export a, b, c
41+
42+
end # module
43+
44+
baremodule Bare
45+
end
46+
47+
### New in 0.6
48+
49+
# where, infix isa, UnionAll
50+
function F{T}(x::T) where T
51+
for i in x
52+
i isa UnionAll && return
53+
end
54+
end
55+
56+
### Miscellaneous
57+
1058
#=
1159
Multi
1260
Line
@@ -24,7 +72,7 @@ function method0(x, y::Int; version::VersionNumber=v"0.1.2")
2472
s = 1.2
2573
変数 = "variable"
2674

27-
if s * 100_000 ≥ 5.2e+10 && true || is(x, nothing)
75+
if s * 100_000 ≥ 5.2e+10 && true || x === nothing
2876
s = 1. + .5im
2977
elseif 1 ∈ [1, 2, 3]
3078
println("s is $s and 変数 is $変数")
@@ -34,13 +82,22 @@ function method0(x, y::Int; version::VersionNumber=v"0.1.2")
3482
end
3583

3684
local var = rand(10)
85+
global g = 44
3786
var[1:5]
3887
var[5:end-1]
3988
var[end]
4089

4190
opt = "-la"
4291
run(`ls $opt`)
4392

93+
try
94+
ccall(:lib, (Ptr{Void},), Ref{C_NULL})
95+
catch
96+
throw(ArgumentError("wat"))
97+
finally
98+
warn("god save the queen")
99+
end
100+
44101
'\u2200' != 'T'
45102

46103
return 5s / 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#empty(friends) {
2+
Try adding some friends!
3+
} ##loop(friends, "friend") {
4+
<li> #(friend.name) </li>
5+
}
6+
7+
#someTag(parameter.list, goes, "here") {
8+
This is an optional body here
9+
}
10+
11+
#index(friends, "0") {
12+
Hello, #(self)!
13+
} ##else() {
14+
Nobody's there!
15+
}
16+
17+
#()
18+
19+
#raw() {
20+
<li> Hello </li>
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
SELECT *
2+
FROM `beer-sample`
3+
WHERE brewery_id IS NOT MISSING AND type="beer"
4+
LIMIT 1;
5+
6+
UPSERT INTO product (KEY, VALUE) VALUES (
7+
"odwalla-juice1", {
8+
"productId": "odwalla-juice1",
9+
"unitPrice": 5.40,
10+
"type": "product",
11+
"color":"red"
12+
}
13+
) RETURNING *;
14+
15+
INFER `beer-sample` WITH {
16+
"sample_size": 10000,
17+
"num_sample_values": 1,
18+
"similarity_metric": 0.0
19+
};

Example/Highlightr/Samples/qml/default.txt

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Window {
2626
nameFilters: ["*.png", "*.jpg", "*.gif"]
2727
}
2828
Component.onCompleted: {
29+
var x;
2930
x = Math.random() * root.width - width / 2
3031
rotation = Math.random() * 13 - 6
3132
if (pinch.scale > 0) {

0 commit comments

Comments
 (0)