Skip to content

Commit 2cecc10

Browse files
committed
Reference examples now use syntax highlighting
1 parent d71e267 commit 2cecc10

File tree

326 files changed

+7607
-7596
lines changed

Some content is hidden

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

326 files changed

+7607
-7596
lines changed

_build/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ pandoc = /usr/bin/pandoc
1919
mkdir = @mkdir -p $(dir $@)
2020
out = _out
2121
pandoc_options=--from markdown-tex_math_dollars --to html5 --syntax-definition=smallbasic.xml
22+
pandoc_ide_options=--from markdown-tex_math_dollars --to html5
2223
bas = $(patsubst layouts/%.html, $(out)/%.bas, $(wildcard layouts/*.html))
2324
pages = $(patsubst pages/%.markdown, $(out)/pages3/%.html, $(wildcard pages/*.markdown))
2425
posts = $(patsubst posts/%.markdown, $(out)/posts3/%.html, $(wildcard posts/*.markdown))
2526
scripts = $(patsubst scripts/%.html, $(out)/scripts2/%.html, $(wildcard scripts/*.html))
2627
reference = $(patsubst reference/%.markdown, $(out)/reference3/%.html, $(wildcard reference/*.markdown))
2728
reference_txt = $(patsubst reference/%.markdown, $(out)/reference_txt/%.txt, $(wildcard reference/*.markdown))
29+
reference_ide = $(patsubst reference/%.markdown, $(out)/reference_ide/%.html, $(wildcard reference/*.markdown))
2830

2931
# rules
3032
.data: reference.json page.bas site.bas mkdata.bas includes/header.html
@@ -35,7 +37,11 @@ $(out)/%.bas: layouts/%.html .data
3537
$(mkdir)
3638
$(sbasic) mkpage.bas $< > $@
3739

38-
$(out)/reference1/%.html: reference/%.markdown
40+
$(out)/reference0/%.markdown: reference/%.markdown
41+
$(mkdir)
42+
$(sbasic) mkhl.bas $< > $@
43+
44+
$(out)/reference1/%.html: $(out)/reference0/%.markdown $(bas)
3945
$(mkdir)
4046
$(pandoc) $(pandoc_options) -o $@ $<
4147

@@ -87,7 +93,11 @@ $(out)/reference_txt/%.txt: reference/%.markdown
8793
$(mkdir)
8894
$(pandoc) --from markdown-tex_math_dollars --to plain -o $@ $<
8995

90-
all: $(reference) $(out)/sbref.txt $(out)/sbasic_ref.csv $(pages) $(posts) $(scripts)
96+
$(out)/reference_ide/%.html: reference/%.markdown
97+
$(mkdir)
98+
$(pandoc) $(pandoc_ide_options) -o $@ $<
99+
100+
all: $(reference) $(reference_ide) $(out)/sbref.txt $(out)/sbasic_ref.csv $(pages) $(posts) $(scripts)
91101
@mkdir -p ../reference/ide
92102
@mkdir -p ../pages
93103
@mkdir -p ../posts

_build/deploy.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ for package in ref
1515
endif
1616
copy in_filename, out_filename
1717

18-
in_filename = "_out/reference1/" + item.nodeId + "-" + lower(package) + "-" + translate(lower(item.keyword), " ", "") + ".html"
18+
in_filename = "_out/reference_ide/" + item.nodeId + "-" + lower(package) + "-" + translate(lower(item.keyword), " ", "") + ".html"
1919
out_filename = "../reference/ide/" + item.nodeId + ".html"
2020
if (not exist(in_filename)) then
2121
throw "File does not exist:" + in_filename

_build/mkhl.bas

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'
2+
' adds syntax highlight handling for code blocks
3+
'
4+
5+
tload trim(command), buffer
6+
inBlock = false
7+
for s in buffer
8+
if (trim(s) == "```smallbasic") then
9+
' highlight marker already applied here
10+
print(s)
11+
inBlock = true
12+
else if (trim(s) == "```" || trim(s) == "~~~") then
13+
' block start or end
14+
if (inBlock) then
15+
print "```"
16+
else
17+
print "```smallbasic"
18+
endif
19+
inBlock = !inBlock
20+
else
21+
print(s)
22+
endif
23+
next

_build/reference/1015-console-definekey.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Keycodes for PC keyboard
3737

3838
Example 1: Bind keystroke for left and right arrow key
3939

40-
```smallbasic
40+
```
4141
defineKey 0xFF04, Increase 'Left arrow
4242
defineKey 0xFF05, Decrease 'Right arrow
4343
@@ -59,13 +59,13 @@ wend
5959

6060
Example 2: Unbind a keystroke
6161

62-
```smallbasic
62+
```
6363
DEFINEKEY 0xFF04, 0
6464
```
6565

6666
Example 3: Etch-a-Sketch
6767

68-
```smallbasic
68+
```
6969
' DEFINEKEY demo.bas SmallBASIC 0.12.2 [B+=MGA] 2016-03-30
7070
'remember Etch-A-Sketch?
7171
'definekey key,sub
@@ -133,7 +133,7 @@ end
133133

134134
Example 4: This example is outdated and just a reference for buttons in PALM OS
135135

136-
```smallbasic
136+
```
137137
' Note:
138138
' * You may Include "definekey_const.bas" file in another file to make your code more clear.
139139
'

_build/reference/521-console-at.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Moves the console cursor to the specified position. x,y are in pixels.
66

7-
```smallbasic
7+
```
88
at 100,100
99
print "This text starts at pixel 100,100"
1010
```

_build/reference/524-console-cls.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Clears the screen.
66

7-
```smallbasic
7+
```
88
print "Test"
99
CLS
1010
```

_build/reference/525-console-form.markdown

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The type attribute can be one of the following:
7272

7373
### Example 1: Creating a push button using callback function
7474

75-
```smallbasic
75+
```
7676
button.type = "button"
7777
button.x = 120
7878
button.y = 120
@@ -99,7 +99,7 @@ end
9999

100100
### Example 2: Creating a push button using doEvents result
101101

102-
```smallbasic
102+
```
103103
button.type = "button"
104104
button.x = 120
105105
button.y = 120
@@ -125,7 +125,7 @@ f.close()
125125

126126
### Example 3: Creating a label
127127

128-
```smallbasic
128+
```
129129
l.type = "label"
130130
l.x = 120
131131
l.y = 120
@@ -145,7 +145,7 @@ f.close()
145145

146146
### Example 4: Creating a link to an external website
147147

148-
```smallbasic
148+
```
149149
l.type = "link"
150150
l.x = 120
151151
l.y = 120
@@ -167,7 +167,7 @@ f.close()
167167

168168
### Example 5: Creating a listbox
169169

170-
```smallbasic
170+
```
171171
l.type = "listbox"
172172
l.x = 120
173173
l.y = 120
@@ -196,7 +196,7 @@ f.close()
196196

197197
### Example 6: Creating a dropdown listbox
198198

199-
```smallbasic
199+
```
200200
l.type = "choice"
201201
l.x = 120
202202
l.y = 120
@@ -224,7 +224,7 @@ f.close()
224224

225225
### Example 7: Creating a text input field
226226

227-
```smallbasic
227+
```
228228
t.type = "text"
229229
t.x = 120
230230
t.y = 120
@@ -266,7 +266,7 @@ end
266266
In this example a callback function will be used. If you want to use the doEvents result instead,
267267
have a look at example 2.
268268

269-
```smallbasic
269+
```
270270
' Create a simple button and save it as png
271271
' If you have already an image for you button,
272272
' this part is not necessary.
@@ -301,7 +301,7 @@ end
301301

302302
### Example 9: One more example
303303

304-
```smallbasic
304+
```
305305
f.handleKeys = 0
306306
' create some buttons
307307
button1.y = 120

_build/reference/527-console-input.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Reads text from keyboard and stores it in the variable `var`. The string `prompt
66

77
### Example 1: Using a single var
88

9-
```smallbasic
9+
```
1010
input "How old are you?", age
1111
print age
1212
```
1313

1414
### Example 2: Using multiple vars
1515

16-
```smallbasic
16+
```
1717
input "Input three numbers: ", a, b, c ' Input i.e. 1,2,3
1818
print a, b, c
1919
```

_build/reference/528-console-lineinput.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Reads a whole text line from file or console and stores it in the string `var`.
66

77
### Example 1: Read from console
88

9-
```smallbasic
9+
```
1010
LINEINPUT S
1111
PRINT S
1212
```
1313

1414
### Example 2: Read from file
1515

16-
```smallbasic
16+
```
1717
' create a file
1818
open "File.txt" for output as #1
1919

_build/reference/529-console-linput.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Reads a whole text line from file or console and stores it in the string `var`.
66

77
### Example 1: Read from console
88

9-
```smallbasic
9+
```
1010
LINPUT S
1111
PRINT S
1212
```
1313

1414
### Example 2: Read from file
1515

16-
```smallbasic
16+
```
1717
' create a file
1818
open "File.txt" for output as #1
1919

0 commit comments

Comments
 (0)