diff options
author | Case Duckworth | 2024-02-06 22:12:47 -0600 |
---|---|---|
committer | Case Duckworth | 2024-02-06 22:12:47 -0600 |
commit | 3ca15b7de0d147c400199c5040a7f87ea92b0c32 (patch) | |
tree | e3d272e459f4dfcbd2f7e0f62ea20580895abe8a | |
parent | Add nl() function (diff) | |
download | subtext-3ca15b7de0d147c400199c5040a7f87ea92b0c32.tar.gz subtext-3ca15b7de0d147c400199c5040a7f87ea92b0c32.zip |
Update readme
-rw-r--r-- | readme.html | 69 | ||||
-rw-r--r-- | readme.st | 88 |
2 files changed, 152 insertions, 5 deletions
diff --git a/readme.html b/readme.html index b6e2ec2..a42f9a9 100644 --- a/readme.html +++ b/readme.html | |||
@@ -18,7 +18,7 @@ without having to remember all the arcane two-letter requests and macros.</p> | |||
18 | 18 | ||
19 | <h2>Quickstart</h2> | 19 | <h2>Quickstart</h2> |
20 | <p>An easy and quick way to start with <code>subtext</code> is to build this | 20 | <p>An easy and quick way to start with <code>subtext</code> is to build this |
21 | <a href="/subtext/tree/readme.st">README</a>: | 21 | <a href=/subtext/tree/readme.st>README</a>: |
22 | <pre><code>make readme</code></pre> | 22 | <pre><code>make readme</code></pre> |
23 | Of course, I'd recommend reading readme.st in this repo | 23 | Of course, I'd recommend reading readme.st in this repo |
24 | to get a feel for the syntax as well. | 24 | to get a feel for the syntax as well. |
@@ -61,10 +61,73 @@ which by default is the current directory.</dd></dl> | |||
61 | that need to be done at awk-time.</p> | 61 | that need to be done at awk-time.</p> |
62 | 62 | ||
63 | <h3>Shell layer: <code>#</code></h3> | 63 | <h3>Shell layer: <code>#</code></h3> |
64 | 64 | <p>So what does <code>subtext</code> do? | |
65 | <i>todo</i> | 65 | It takes an input file or stream and converts it to a shell script |
66 | which you can then pipe through <code>sh(1)</code>. | ||
67 | But it doesn't | ||
68 | <i>just</i> | ||
69 | do that. | ||
70 | <code>subtext</code> | ||
71 | also outputs various functions and variables and what-not | ||
72 | to set up the environment in which the source document is expanded. | ||
73 | Starting a line with <code>#</code> puts the rest of the line in the code part, | ||
74 | enabling you to set a title, say, with <code #title='Some title'></code> or | ||
75 | define a function for a commonly-used thing in your file. | ||
76 | For this README, I've written | ||
77 | <code>#subtext()(code subtext)</code> | ||
78 | so I save about five characters every time.</p> | ||
66 | 79 | ||
67 | <h3>Text layer: <code>.</code></h3> | 80 | <h3>Text layer: <code>.</code></h3> |
81 | <p>The "text layer" of subtext is actually expanded to a shell here-doc | ||
82 | so that you can use stuff like | ||
83 | <code>$(...)</code> | ||
84 | to call shell functions. | ||
85 | But don't worry – I've made it easier to not shoot yourself in the foot. | ||
86 | One $ is changed to \$ in the expansion, | ||
87 | and more than one $ is changed to one less. | ||
88 | So $$$ becomes $$, etc. | ||
89 | if you really want to put the process number in your output. | ||
90 | Oh, and ` are all escaped. | ||
91 | Those were a bad idea from go.</p> | ||
92 | <p>In addition, lines beginning with | ||
93 | <code>.</code> | ||
94 | expand to | ||
95 | <code>$(...)</code>, | ||
96 | and lines beginning with | ||
97 | <code>..COMMAND [ARGS]</code> | ||
98 | expand to | ||
99 | <code>$(COMMAND ARGS << ..</code> | ||
100 | and close the here-doc with | ||
101 | <code>..</code> | ||
102 | on a line by itself.</p> | ||
103 | <p>You can add the | ||
104 | <code><< END-MARKER</code> | ||
105 | yourself if you want to specify your own end-marker.</p> | ||
106 | <p>Basically, this means you can write | ||
107 | <pre><code>.h1 My cool article | ||
108 | |||
109 | Here is a cool article. | ||
110 | It is | ||
111 | .i really | ||
112 | cool. | ||
113 | |||
114 | Here's what someone said about it: | ||
115 | |||
116 | ..blockquote cite="A fan" | ||
117 | Wow, what a cool article! | ||
118 | ..</code></pre></p> | ||
119 | <p>The above translates to</p> | ||
120 | <section style="border:1px solid;padding:0.5em"><h1>My cool article</h1> | ||
121 | <p>Here is a cool article. | ||
122 | It is | ||
123 | <i>really</i> | ||
124 | cool.</p> | ||
125 | <p>Here's what someone said about it:</p> | ||
126 | <blockquote cite=A fan>Wow, what a cool article!</blockquote></section> | ||
127 | <p>Since this README was generated from subtext source, | ||
128 | look at readme.st to get a better feel for the syntax.</p> | ||
129 | |||
130 | <h2>Using <code>subtext</code></h2> | ||
68 | 131 | ||
69 | <i>todo</i> | 132 | <i>todo</i> |
70 | 133 | ||
diff --git a/readme.st b/readme.st index 1344818..2315ad3 100644 --- a/readme.st +++ b/readme.st | |||
@@ -25,7 +25,8 @@ without having to remember all the arcane two-letter requests and macros. | |||
25 | 25 | ||
26 | .h2 Quickstart | 26 | .h2 Quickstart |
27 | 27 | ||
28 | An easy and quick way to start with $$(code subtext) is to build this README: | 28 | An easy and quick way to start with $$(code subtext) is to build this |
29 | .a href="/subtext/tree/readme.st" README : | ||
29 | ..code | 30 | ..code |
30 | make readme | 31 | make readme |
31 | .. | 32 | .. |
@@ -91,10 +92,93 @@ that need to be done at awk-time. | |||
91 | % filter, and making it parse shell syntax does not seem like a good time. | 92 | % filter, and making it parse shell syntax does not seem like a good time. |
92 | .h3 Shell layer: $$(code \#) | 93 | .h3 Shell layer: $$(code \#) |
93 | 94 | ||
94 | .i todo | 95 | So what does $$(subtext) do? |
96 | It takes an input file or stream and converts it to a shell script | ||
97 | which you can then pipe through $$(code "sh(1)"). | ||
98 | But it doesn't | ||
99 | .i just | ||
100 | do that. | ||
101 | .subtext | ||
102 | also outputs various functions and variables and what-not | ||
103 | to set up the environment in which the source document is expanded. | ||
104 | Starting a line with $$(code \#) puts the rest of the line in the code part, | ||
105 | enabling you to set a title, say, with $$(code "#title='Some title'") or | ||
106 | define a function for a commonly-used thing in your file. | ||
107 | For this README, I've written | ||
108 | .code #subtext()(code subtext) | ||
109 | so I save about five characters every time. | ||
95 | 110 | ||
96 | .h3 Text layer: $$(code .) | 111 | .h3 Text layer: $$(code .) |
97 | 112 | ||
113 | The "text layer" of subtext is actually expanded to a shell here-doc | ||
114 | so that you can use stuff like | ||
115 | .code \$(...) | ||
116 | to call shell functions. | ||
117 | But don't worry – I've made it easier to not shoot yourself in the foot. | ||
118 | One $ is changed to \\$ in the expansion, | ||
119 | and more than one $ is changed to one less. | ||
120 | So \$\$$ becomes \$$, etc. | ||
121 | if you really want to put the process number in your output. | ||
122 | Oh, and ` are all escaped. | ||
123 | Those were a bad idea from go. | ||
124 | |||
125 | In addition, lines beginning with | ||
126 | .code . | ||
127 | expand to | ||
128 | .code \$(...) , | ||
129 | and lines beginning with | ||
130 | .code ..COMMAND [ARGS] | ||
131 | expand to | ||
132 | .code \$(COMMAND ARGS << .. | ||
133 | and close the here-doc with | ||
134 | .code .. | ||
135 | on a line by itself. | ||
136 | |||
137 | You can add the | ||
138 | .code << END-MARKER | ||
139 | yourself if you want to specify your own end-marker. | ||
140 | |||
141 | Basically, this means you can write | ||
142 | ..code << /code | ||
143 | \.h1 My cool article | ||
144 | .nl | ||
145 | Here is a cool article. | ||
146 | It is | ||
147 | \.i really | ||
148 | cool. | ||
149 | .nl | ||
150 | Here's what someone said about it: | ||
151 | .nl | ||
152 | \..blockquote cite="A fan" | ||
153 | Wow, what a cool article! | ||
154 | \.. | ||
155 | /code | ||
156 | |||
157 | The above translates to | ||
158 | |||
159 | % NB: I don't have `section' written in html.st.sh, and I don't really | ||
160 | % want to bother here ... but I made @ an alias for html_el, | ||
161 | % so it all works ^_^ | ||
162 | ..@ section 'style="border:1px solid;padding:0.5em"' << //bq | ||
163 | .h1 My cool article | ||
164 | |||
165 | Here is a cool article. | ||
166 | It is | ||
167 | .i really | ||
168 | cool. | ||
169 | |||
170 | Here's what someone said about it: | ||
171 | |||
172 | ..blockquote cite="A fan" | ||
173 | Wow, what a cool article! | ||
174 | .. | ||
175 | //bq | ||
176 | |||
177 | Since this README was generated from subtext source, | ||
178 | look at readme.st to get a better feel for the syntax. | ||
179 | |||
180 | .h2 Using $$(subtext) | ||
181 | |||
98 | .i todo | 182 | .i todo |
99 | 183 | ||
100 | .h2 Contributing | 184 | .h2 Contributing |