Skip to content

Commit b7ef2f3

Browse files
nzakasmdjermanovic
andauthored
docs: Enable pretty code formatter output (#17635)
* docs: Enable pretty code formatter output fixes #17505 * Add note about formatted output * Update templates/formatter-examples.md.ejs Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * Update templates/formatter-examples.md.ejs Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> --------- Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
1 parent 0bcb9a8 commit b7ef2f3

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

templates/formatter-examples.md.ejs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ You can specify a formatter using the `--format` or `-f` flag in the CLI. For ex
1414

1515
The built-in formatter options are:
1616

17-
<% Object.keys(formatterResults).forEach(function(formatterName) { -%>
17+
<% Object.keys(formatterResults).forEach(formatterName => { -%>
1818
* [<%= formatterName %>](#<%= formatterName %>)
1919
<% }) -%>
2020

@@ -56,19 +56,36 @@ npx eslint --format <Add formatter here> fullOfProblems.js
5656
```
5757

5858
## Built-In Formatter Options
59-
<% Object.keys(formatterResults).forEach(function(formatterName) { -%>
59+
<% Object.keys(formatterResults).forEach(formatterName => { -%>
6060
6161
### <%= formatterName %>
6262
6363
<%= formatterResults[formatterName].description %>
64+
<% if (formatterName !== "html") { -%>
65+
<%
66+
let codeFormat = "text";
67+
let output = formatterResults[formatterName].result;
68+
let outputNote = "Example output:";
6469
65-
Example output:
70+
if (output.startsWith("\u003C?xml")) {
71+
codeFormat = "xml";
72+
}
6673
67-
<% if (formatterName !== "html") { -%>
68-
```text
69-
<%- formatterResults[formatterName].result %>
74+
if (formatterName.includes("json")) {
75+
codeFormat = "json";
76+
output = JSON.stringify(JSON.parse(output), null, 4);
77+
outputNote = "Example output (formatted for easier reading):";
78+
}
79+
%>
80+
<%= outputNote %>
81+
82+
```<%= codeFormat %>
83+
<%- output %>
7084
```
7185
<% } else {-%>
86+
87+
Example output:
88+
7289
<iframe src="html-formatter-example.html" width="100%" height="460px"></iframe>
7390
<% } -%>
7491
<% }) -%>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy