Skip to content

Commit 9419bf3

Browse files
render kbd, samp and tt tags as inline code
1 parent 1894295 commit 9419bf3

File tree

6 files changed

+76
-5
lines changed

6 files changed

+76
-5
lines changed

commonmark.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ var commonmark = []Rule{
294294
},
295295
},
296296
{
297-
Filter: []string{"code"},
297+
Filter: []string{"code", "kbd", "samp", "tt"},
298298
Replacement: func(_ string, selec *goquery.Selection, opt *Options) *string {
299299
code := getCodeContent(selec)
300300

testdata/TestCommonmark/pre_code/goldmark.golden

+8
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,11 @@ _pre_
101101
Cool!
102102

103103
</code></pre>
104+
<hr>
105+
<p>The telnet client should display: <code>Local Echo is on</code></p>
106+
<p>A simple equation: x = y + 2</p>
107+
<p>When the process is complete, the utility will output the text
108+
<code>Scan complete. Found N results.</code> You can then
109+
proceed to the next step.</p>
110+
<p>Use the command <code>help mycommand</code> to view documentation
111+
for the command &quot;mycommand&quot;.</p>

testdata/TestCommonmark/pre_code/input.html

+25-1
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,28 @@ <h4 id="html">HTML:</h4>
210210
<pre>_pre_</pre>
211211
Cool!
212212

213-
</code><pre>
213+
</code></pre>
214+
215+
216+
217+
<hr />
218+
219+
220+
221+
<!-- The Teletype Text element -->
222+
<p>The telnet client should display: <tt>Local Echo is on</tt></p>
223+
224+
225+
<!-- The Variable element -->
226+
<p>A simple equation: <var>x</var> = <var>y</var> + 2 </p>
227+
228+
229+
<!-- The Sample Output element -->
230+
<p>When the process is complete, the utility will output the text
231+
<samp>Scan complete. Found <em>N</em> results.</samp> You can then
232+
proceed to the next step.</p>
233+
234+
235+
<!-- The Keyboard Input element -->
236+
<p>Use the command <kbd>help mycommand</kbd> to view documentation
237+
for the command "mycommand".</p>

testdata/TestCommonmark/pre_code/output.fenced_backtick.golden

+14-1
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,17 @@ _code_
164164
_pre_
165165
Cool!
166166

167-
```
167+
```
168+
169+
* * *
170+
171+
The telnet client should display: `Local Echo is on`
172+
173+
A simple equation: x = y \+ 2
174+
175+
When the process is complete, the utility will output the text
176+
`Scan complete. Found N results.` You can then
177+
proceed to the next step.
178+
179+
Use the command `help mycommand` to view documentation
180+
for the command "mycommand".

testdata/TestCommonmark/pre_code/output.fenced_tilde.golden

+14-1
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,17 @@ _code_
164164
_pre_
165165
Cool!
166166

167-
~~~
167+
~~~
168+
169+
* * *
170+
171+
The telnet client should display: `Local Echo is on`
172+
173+
A simple equation: x = y \+ 2
174+
175+
When the process is complete, the utility will output the text
176+
`Scan complete. Found N results.` You can then
177+
proceed to the next step.
178+
179+
Use the command `help mycommand` to view documentation
180+
for the command "mycommand".

testdata/TestCommonmark/pre_code/output.indented.golden

+14-1
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,17 @@ _code_
164164
_pre_
165165
Cool!
166166

167-
```
167+
```
168+
169+
* * *
170+
171+
The telnet client should display: `Local Echo is on`
172+
173+
A simple equation: x = y \+ 2
174+
175+
When the process is complete, the utility will output the text
176+
`Scan complete. Found N results.` You can then
177+
proceed to the next step.
178+
179+
Use the command `help mycommand` to view documentation
180+
for the command "mycommand".

0 commit comments

Comments
 (0)