Skip to content

Commit 5e1a244

Browse files
committed
Update the MarkdownRenderer to support HTML tags
1 parent 8745fd9 commit 5e1a244

File tree

6 files changed

+79
-3
lines changed

6 files changed

+79
-3
lines changed

apps/api-documenter/src/utils/MarkdownRenderer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export class MarkdownRenderer {
197197
case '\n':
198198
case ' ':
199199
case '[':
200+
case '>':
200201
// okay to put a symbol
201202
break;
202203
default:
@@ -227,6 +228,10 @@ export class MarkdownRenderer {
227228
writer.write(parts[3]); // write trailing whitespace
228229
}
229230
break;
231+
case 'html-tag':
232+
// write the HTML element verbatim into the output
233+
writer.write(element.token);
234+
break;
230235
case 'code':
231236
writer.write('`');
232237
if (context.insideTable) {

apps/api-documenter/src/utils/test/ExpectedOutput.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ HTML escape: "
3838

3939
3 or more hyphens: - -- \-\-\- \-\-\-- \-\-\--- \-\-\-\-\-\-
4040

41+
<b>bold</b>

apps/api-documenter/src/utils/test/MarkdownRenderer.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ describe('MarkdownPageRenderer', () => {
5959
markupPage.elements.push(...Markup.createTextParagraphs(
6060
'3 or more hyphens: - -- --- ---- ----- ------\n\n'));
6161

62+
markupPage.elements.push(...[
63+
Markup.createHtmlTag('<b>'),
64+
...Markup.createTextElements('bold'),
65+
Markup.createHtmlTag('</b>')
66+
]);
67+
6268
const outputFilename: string = path.join(outputFolder, 'ActualOutput.md');
6369
fsx.writeFileSync(outputFilename, MarkdownRenderer.renderElements([markupPage], { }));
6470

build-tests/api-extractor-test-05/etc/api-extractor-test-05.api.json

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,71 @@
107107
"remarks": [
108108
{
109109
"kind": "text",
110-
"text": "<table> <tr> <td>John</td> <td>Doe</td> </tr> </table>"
110+
"text": ""
111+
},
112+
{
113+
"kind": "html-tag",
114+
"token": "<table>"
115+
},
116+
{
117+
"kind": "text",
118+
"text": " "
119+
},
120+
{
121+
"kind": "html-tag",
122+
"token": "<tr>"
123+
},
124+
{
125+
"kind": "text",
126+
"text": " "
127+
},
128+
{
129+
"kind": "html-tag",
130+
"token": "<td>"
131+
},
132+
{
133+
"kind": "text",
134+
"text": "John"
135+
},
136+
{
137+
"kind": "html-tag",
138+
"token": "</td>"
139+
},
140+
{
141+
"kind": "text",
142+
"text": " "
143+
},
144+
{
145+
"kind": "html-tag",
146+
"token": "<td>"
147+
},
148+
{
149+
"kind": "text",
150+
"text": "Doe"
151+
},
152+
{
153+
"kind": "html-tag",
154+
"token": "</td>"
155+
},
156+
{
157+
"kind": "text",
158+
"text": " "
159+
},
160+
{
161+
"kind": "html-tag",
162+
"token": "</tr>"
163+
},
164+
{
165+
"kind": "text",
166+
"text": " "
167+
},
168+
{
169+
"kind": "html-tag",
170+
"token": "</table>"
171+
},
172+
{
173+
"kind": "text",
174+
"text": ""
111175
}
112176
],
113177
"isBeta": false,

build-tests/api-extractor-test-05/etc/markdown/api-extractor-test-05.docclass1.tableexample.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ tableExample(): void;
1212

1313
## Remarks
1414

15-
&lt;table&gt; &lt;tr&gt; &lt;td&gt;John&lt;/td&gt; &lt;td&gt;Doe&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;
15+
<table> <tr> <td>John</td> <td>Doe</td> </tr> </table>

build-tests/api-extractor-test-05/etc/yaml/api-extractor-test-05/docclass1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ items:
3636
- string
3737
- uid: api-extractor-test-05.DocClass1.tableExample
3838
summary: 'An example with tables:'
39-
remarks: '&lt;table&gt; &lt;tr&gt; &lt;td&gt;John&lt;/td&gt; &lt;td&gt;Doe&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;'
39+
remarks: <table> <tr> <td>John</td> <td>Doe</td> </tr> </table>
4040
name: tableExample()
4141
fullName: api-extractor-test-05.DocClass1.tableExample
4242
langs:

0 commit comments

Comments
 (0)