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.
- indented code block(4+ spaces) will be executed as q, and results will be put inside markdown's code block
- q code inside ```q blcok will be executed, and results will be put into markdown directly, so you can generate markdown from Q.
show f 1
will generate
show f 1
2 show t: ([] a: 1 2; b: `c`d)
a b
---
1 c
2 d show header t
"|a|b|" -1@body t;
|1|c|
|2|d| show separator t
"\n|-|-|"The following code can be used to generate a markdown table
```q -1@header[t] ,separator[t], body t; ```
Will generate
-1@header[t] ,separator[t], body t;| a | b |
|---|---|
| 1 | c |
| 2 | d |
This README.md is generated by qnote2.q like below.
$ ./qnote2.q README.q > README.mdLibrary Code1
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] # "-"}