You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pay attention to follow the loading instructions to develop Microdown as defined on the readme on the project. You should execute them else you may have problems since a different version of Microdown
16
+
preloaded in Pharo may conflict with the version you will load.
17
+
18
+
19
+
### Getting started
20
+
21
+
#### Model
22
+
Have a look at the document model
23
+
- What is the root of a document?
24
+
- What is the class of the object that represents code block?
25
+
- What is the class that represents italic font?
26
+
27
+
28
+
#### From text to objects
29
+
30
+
- Read the tests to understand how to get an object representing the text?
31
+
- Turn the following text into a document object
32
+
33
+
We will reuse the following text in other exercises. So we store it into a variable.
34
+
```
35
+
miniDoc := '
36
+
# Microdown
37
+
38
+
Microdown is a super cool markdown description language.
39
+
It supports basic markdown but also extensions that are important to write books.
40
+
41
+
42
+
# Architecture
43
+
44
+
Microdown proposes visitors to
45
+
46
+
- Export in LaTeX, HTML
47
+
- Dump the document tree as objects
48
+
- Checkers
49
+
50
+
## Visitors
51
+
52
+
Visitors just visit the structure tree and perform the corresponding actions.
53
+
54
+
## A builder
55
+
56
+
A builder proposes an API to produce Microdown instructions without manipulating text directly.
57
+
It decouples the structure from the actual textual representation. It allows developers to script documentation.
58
+
'
59
+
```
60
+
61
+
- Check that the root of the document is effectively an instance of the class you identified earlier.
62
+
- Navigate some children of the root.
63
+
64
+
#### Programmatically writing a textual document
65
+
66
+
While visitors often go from objects to textual representations, we often need to generate textual
67
+
representations of the manipulated document objects.
68
+
69
+
We could also simply manipulate strings and concatenate them by hand. This, however, would expose
70
+
our program to any simple language evolution. Identify the solution proposed by Microdown.
71
+
72
+
73
+
74
+
75
+
### Table of contents
76
+
77
+
We would like to have a table of content builder. Given a book, the Toc builder will generate a microdown document tree containing references to the corresponding book entities (chapter, section).
78
+
79
+
To achieve this exercise we propose several solutions.
80
+
81
+
#### Generating a plain text TOC
82
+
83
+
Define a simple Visitor that will generate a text. For example
84
+
85
+
```
86
+
vis := SimpleTOCGenerator new.
87
+
vis visit: (Microdown parse: miniDoc)
88
+
vis contents
89
+
>
90
+
91
+
'
92
+
Microdown
93
+
Architecture
94
+
Visitors
95
+
A builder
96
+
'
97
+
98
+
#### Controlling the level
99
+
100
+
Now we can also want to only show sections whose nested in higher than a certain level.
101
+
102
+
```
103
+
vis := SimpleTOCGenerator new.
104
+
vis showOnlyAbove: 1.
105
+
vis visit: (Microdown parse: miniDoc)
106
+
vis contents
107
+
>
108
+
109
+
'
110
+
Microdown
111
+
Architecture
112
+
'
113
+
114
+
#### Showing numbers
115
+
116
+
Now we may want to get the TOC numbered
117
+
118
+
```
119
+
vis := SimpleTOCGenerator new.
120
+
vis showOnlyAbove: 1.
121
+
vis numbered.
122
+
vis visit: (Microdown parse: miniDoc)
123
+
vis contents
124
+
>
125
+
126
+
'
127
+
1 Microdown
128
+
2 Architecture
129
+
'
130
+
131
+
#### Producing Microdown
132
+
133
+
Now we would like to be able to produce Microdown text that represents the TOC.
134
+
This solution should use the textual builder.
135
+
136
+
```
137
+
vis := SimpleTOCGenerator new.
138
+
vis showOnlyAbove: 1.
139
+
vis visit: (Microdown parse: miniDoc)
140
+
vis contents
141
+
>
142
+
143
+
'
144
+
# Microdown
145
+
# Architecture
146
+
'
147
+
148
+
149
+
150
+
151
+
13
152
### Blog and its posts
14
153
15
154
A nice little project is to use Microdown to define a blog and its posts.
@@ -39,9 +178,6 @@ In Section *@anchor1@* we can find Fig. *@figanchor@*.
39
178
We would like to have a checker that reports to the users the set of references (defined using the `*@xxx@*` instruction that are not found.
40
179
41
180
42
-
### Table of contents
43
-
44
-
We would like to have a table of content builder. Given a book, the Toc builder will generate a microdown document tree containing references to the corresponding book entities (chapter, section)
0 commit comments