-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.q
executable file
·49 lines (40 loc) · 1.44 KB
/
README.q
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
f:{x+1}
wrap:{"|",x,"|"};
header:{wrap "|" sv string cols x}
body:{"\n", "\n" sv wrap each "|" sv/:string flip value flip x}
separator:{"\n", wrap "|" sv enlist each count[cols t] # "-"}
\
# A Simple Notebook for Q Programming Language
Given a Q file with a \ (on a single line without space) started comment block at the end of file, with next line
started with # and a space for Markdown level head, and Markdown inside the comment, it will generated a Markdown file
from it:
* The file is a legitimate Q file
* Put q code at the beginning
* Markdown start with a line with single slash \\, and # space on the next line.
* Switch to k mode is not supported. Use 0N! to display like k when needed.
* q code inside ~~~q block will be executed, and results will be put inside markdown's **code block**
* q coed inside ```q blcok will be executed, and results will be put into **markdown** directly, so you
can generate markdown from Q.
## Basic Example:
<pre>
show f 1
</pre>
Will generate
show f 1
## Example usage of header, body and separator functions
show t: ([] a: 1 2; b: `c`d)
show header t
-1@body t;
show separator t
## Example: Generate markdown table from q
The following code can be used to generate a markdown table
<pre>
-1@header[t] ,separator[t], body t;
</pre>
Will generate
-1@header[t] ,separator[t], body t;
## Usage
This README.md is generated by qnote2.q like below.
```bash
$ ./qnote2.q README.q > README.md
```