Skip to content

Commit 6b7f09a

Browse files
nschonniTrott
authored andcommitted
fix: MD046/code-block-style (#2557)
* fix: MD046/code-block-style Code block style of fenced to match nodejs style * fix: MD027/no-multiple-space-blockquote Multiple spaces after blockquote symbol
1 parent ce2f199 commit 6b7f09a

File tree

51 files changed

+1598
-1290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1598
-1290
lines changed

.markdownlint.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"MD024": false,
99
"MD025": false,
1010
"MD026": false,
11-
"MD027": false,
1211
"MD032": false,
1312
"MD033": {
1413
"allowed_elements": [
@@ -29,5 +28,7 @@
2928
"MD036": false,
3029
"MD040": false,
3130
"MD041": false,
32-
"MD046": false
31+
"MD046": {
32+
"style": "fenced"
33+
}
3334
}

locale/ar/docs/guides/anatomy-of-an-http-transaction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ http.createServer((request, response) => {
309309
```
310310

311311
>**ملاحظة:** عند التحقق من الرابط URL بهذه الطريقة، نحن نقوم بشكل من التوجيه "routing".
312-
ويوجد أشكال أخرى للتوجيه بسيطة مثل دالة `بَدَّالَةٌ` `switch` أو معقدة كما في أدوات مثل
313-
[`express`][]. إذا كنت نبحث على شئ يقوم بالتوجيه ولاشئ أخر جرب [`router`][].
312+
ويوجد أشكال أخرى للتوجيه بسيطة مثل دالة `بَدَّالَةٌ` `switch` أو معقدة كما في أدوات مثل
313+
[`express`][]. إذا كنت نبحث على شئ يقوم بالتوجيه ولاشئ أخر جرب [`router`][].
314314

315315
رائع! الآن نستقر على تبسيط هذا وتذكر كائنات الطلب `request` هي تدقف قابل للقراءة
316316
[`ReadableStream`][] و كائنات الجواب `response` هي تدفق قابل للكتابة [`WritableStream`][].

locale/en/blog/feature/streams2.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ feedback.
109109

110110
# Stream
111111

112-
Stability: 2 - Unstable
112+
> Stability: 2 - Unstable
113113
114114
A stream is an abstract interface implemented by various objects in
115115
Node. For example a request to an HTTP server is a stream, as is
@@ -494,7 +494,9 @@ This function returns the `destination` stream.
494494
495495
For example, emulating the Unix `cat` command:
496496
497-
process.stdin.pipe(process.stdout);
497+
```javascript
498+
process.stdin.pipe(process.stdout);
499+
```
498500
499501
By default `end()` is called on the destination when the source stream
500502
emits `end`, so that `destination` is no longer writable. Pass `{ end:
@@ -503,10 +505,12 @@ false }` as `options` to keep the destination stream open.
503505
This keeps `writer` open so that "Goodbye" can be written at the
504506
end.
505507
506-
reader.pipe(writer, { end: false });
507-
reader.on("end", function() {
508-
writer.end("Goodbye\n");
509-
});
508+
```javascript
509+
reader.pipe(writer, { end: false });
510+
reader.on("end", function() {
511+
writer.end("Goodbye\n");
512+
});
513+
```
510514
511515
Note that `process.stderr` and `process.stdout` are never closed until
512516
the process exits, regardless of the specified options.

locale/en/blog/release/v0.8.6.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ supported Unix operating systems (Linux, Darwin, and SmartOS). To use
1414
the binary distribution tarballs, you can unpack them directly into a
1515
destination directory:
1616

17-
cd ~/node/ # or /usr/local if you're feeling brave
18-
tar xzvf /path/to/binary.tar.gz --strip=1
17+
```
18+
cd ~/node/ # or /usr/local if you're feeling brave
19+
tar xzvf /path/to/binary.tar.gz --strip=1
20+
```
1921

2022
This is an experimental feature. Please use it and provide feedback.
2123

locale/en/knowledge/HTTP/clients/how-to-create-a-HTTP-request.md

Lines changed: 74 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,82 +12,88 @@ Another extremely common programming task is making an HTTP request to a web ser
1212

1313
As an example, we are going to preform a GET request to <https://www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new> (which returns a random integer between 1 and 10) and print the result to the console.
1414

15-
var http = require('http');
15+
```javascript
16+
var http = require('http');
1617

17-
//The url we want is: 'www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
18-
var options = {
19-
host: 'www.random.org',
20-
path: '/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
21-
};
18+
//The url we want is: 'www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
19+
var options = {
20+
host: 'www.random.org',
21+
path: '/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
22+
};
2223

23-
callback = function(response) {
24-
var str = '';
24+
callback = function(response) {
25+
var str = '';
2526

26-
//another chunk of data has been received, so append it to `str`
27-
response.on('data', function (chunk) {
28-
str += chunk;
29-
});
27+
//another chunk of data has been received, so append it to `str`
28+
response.on('data', function (chunk) {
29+
str += chunk;
30+
});
3031

31-
//the whole response has been received, so we just print it out here
32-
response.on('end', function () {
33-
console.log(str);
34-
});
35-
}
32+
//the whole response has been received, so we just print it out here
33+
response.on('end', function () {
34+
console.log(str);
35+
});
36+
}
3637

37-
http.request(options, callback).end();
38+
http.request(options, callback).end();
39+
```
3840

3941
Making a POST request is just as easy. We will make a POST request to `www.nodejitsu.com:1337` which is running a server that will echo back what we post. The code for making a POST request is almost identical to making a GET request, just a few simple modifications:
4042

41-
var http = require('http');
42-
43-
//The url we want is `www.nodejitsu.com:1337/`
44-
var options = {
45-
host: 'www.nodejitsu.com',
46-
path: '/',
47-
//since we are listening on a custom port, we need to specify it by hand
48-
port: '1337',
49-
//This is what changes the request to a POST request
50-
method: 'POST'
51-
};
52-
53-
callback = function(response) {
54-
var str = ''
55-
response.on('data', function (chunk) {
56-
str += chunk;
57-
});
58-
59-
response.on('end', function () {
60-
console.log(str);
61-
});
62-
}
63-
64-
var req = http.request(options, callback);
65-
//This is the data we are posting, it needs to be a string or a buffer
66-
req.write("hello world!");
67-
req.end();
43+
```javascript
44+
var http = require('http');
45+
46+
//The url we want is `www.nodejitsu.com:1337/`
47+
var options = {
48+
host: 'www.nodejitsu.com',
49+
path: '/',
50+
//since we are listening on a custom port, we need to specify it by hand
51+
port: '1337',
52+
//This is what changes the request to a POST request
53+
method: 'POST'
54+
};
55+
56+
callback = function(response) {
57+
var str = ''
58+
response.on('data', function (chunk) {
59+
str += chunk;
60+
});
61+
62+
response.on('end', function () {
63+
console.log(str);
64+
});
65+
}
66+
67+
var req = http.request(options, callback);
68+
//This is the data we are posting, it needs to be a string or a buffer
69+
req.write("hello world!");
70+
req.end();
71+
```
6872

6973
Throwing in custom headers is just a tiny bit harder. On `www.nodejitsu.com:1338` we are running a server that will print out the `custom` header. So we will just make a quick request to it:
7074

71-
var http = require('http');
72-
73-
var options = {
74-
host: 'www.nodejitsu.com',
75-
path: '/',
76-
port: '1338',
77-
//This is the only line that is new. `headers` is an object with the headers to request
78-
headers: {'custom': 'Custom Header Demo works'}
79-
};
80-
81-
callback = function(response) {
82-
var str = ''
83-
response.on('data', function (chunk) {
84-
str += chunk;
85-
});
86-
87-
response.on('end', function () {
88-
console.log(str);
89-
});
90-
}
91-
92-
var req = http.request(options, callback);
93-
req.end();
75+
```javascript
76+
var http = require('http');
77+
78+
var options = {
79+
host: 'www.nodejitsu.com',
80+
path: '/',
81+
port: '1338',
82+
//This is the only line that is new. `headers` is an object with the headers to request
83+
headers: {'custom': 'Custom Header Demo works'}
84+
};
85+
86+
callback = function(response) {
87+
var str = ''
88+
response.on('data', function (chunk) {
89+
str += chunk;
90+
});
91+
92+
response.on('end', function () {
93+
console.log(str);
94+
});
95+
}
96+
97+
var req = http.request(options, callback);
98+
req.end();
99+
```

locale/en/knowledge/HTTP/servers/how-to-create-a-HTTP-server.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ Making a simple HTTP server in Node.js has become the de facto 'hello world' for
1111

1212
Let's take a look at a very simple example:
1313

14-
const http = require('http');
14+
```javascript
15+
const http = require('http');
1516

16-
const requestListener = function (req, res) {
17-
res.writeHead(200);
18-
res.end('Hello, World!\n');
19-
}
17+
const requestListener = function (req, res) {
18+
res.writeHead(200);
19+
res.end('Hello, World!\n');
20+
}
2021

21-
const server = http.createServer(requestListener);
22-
server.listen(8080);
22+
const server = http.createServer(requestListener);
23+
server.listen(8080);
24+
```
2325

2426
Save this in a file called `server.js` - run `node server.js`, and your program will hang there... it's waiting for connections to respond to, so you'll have to give it one if you want to see it do anything. Try opening up a browser, and typing `localhost:8080` into the location bar. If everything has been set up correctly, you should see your server saying hello!
2527

locale/en/knowledge/HTTP/servers/how-to-create-a-HTTPS-server.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,38 @@ We need to start out with a word about SSL certificates. Speaking generally, th
1818

1919
To generate a self-signed certificate, run the following in your shell:
2020

21-
openssl genrsa -out key.pem
22-
openssl req -new -key key.pem -out csr.pem
23-
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
24-
rm csr.pem
21+
```
22+
openssl genrsa -out key.pem
23+
openssl req -new -key key.pem -out csr.pem
24+
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
25+
rm csr.pem
26+
```
2527

2628
This should leave you with two files, `cert.pem` (the certificate) and `key.pem` (the private key). Put these files in the same directory as your Node.js server file. This is all you need for a SSL connection. So now you set up a quick hello world example (the biggest difference between https and [http](/en/knowledge/HTTP/servers/how-to-create-a-HTTP-server/) is the `options` parameter):
2729

28-
const https = require('https');
29-
const fs = require('fs');
30+
```javascript
31+
const https = require('https');
32+
const fs = require('fs');
3033

31-
const options = {
32-
key: fs.readFileSync('key.pem'),
33-
cert: fs.readFileSync('cert.pem')
34-
};
34+
const options = {
35+
key: fs.readFileSync('key.pem'),
36+
cert: fs.readFileSync('cert.pem')
37+
};
3538

36-
https.createServer(options, function (req, res) {
37-
res.writeHead(200);
38-
res.end("hello world\n");
39-
}).listen(8000);
39+
https.createServer(options, function (req, res) {
40+
res.writeHead(200);
41+
res.end("hello world\n");
42+
}).listen(8000);
43+
```
4044

4145
NODE PRO TIP: Note `fs.readFileSync` - unlike `fs.readFile`, `fs.readFileSync` will block the entire process until it completes. In situations like this - loading vital configuration data - the `sync` functions are okay. In a busy server, however, using a synchronous function during a request will force the server to deal with the requests one by one!
4246

4347
> To start your https server, run `node app.js` (here, app.js is name of the file) on the terminal.
4448
4549
Now that your server is set up and started, you should be able to get the file with curl:
4650

47-
curl -k https://localhost:8000
51+
```
52+
curl -k https://localhost:8000
53+
```
4854

4955
or in your browser, by going to https://localhost:8000 .

locale/en/knowledge/HTTP/servers/how-to-handle-multipart-form-data.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,52 @@ Handling form data and file uploads properly is an important and complex problem
1414

1515
This example is taken directly from the `node-formidable` GitHub page, with some additional explanation added.
1616

17-
var formidable = require('formidable'),
18-
http = require('http'),
19-
util = require('util');
17+
```javascript
18+
var formidable = require('formidable'),
19+
http = require('http'),
20+
util = require('util');
2021

21-
http.createServer(function(req, res) {
22+
http.createServer(function(req, res) {
2223

23-
// This if statement is here to catch form submissions, and initiate multipart form data parsing.
24+
// This if statement is here to catch form submissions, and initiate multipart form data parsing.
2425

25-
if (req.url == '/upload' && req.method.toLowerCase() == 'post') {
26+
if (req.url == '/upload' && req.method.toLowerCase() == 'post') {
2627

27-
// Instantiate a new formidable form for processing.
28+
// Instantiate a new formidable form for processing.
2829

29-
var form = new formidable.IncomingForm();
30+
var form = new formidable.IncomingForm();
3031

31-
// form.parse analyzes the incoming stream data, picking apart the different fields and files for you.
32+
// form.parse analyzes the incoming stream data, picking apart the different fields and files for you.
3233

33-
form.parse(req, function(err, fields, files) {
34-
if (err) {
34+
form.parse(req, function(err, fields, files) {
35+
if (err) {
3536

36-
// Check for and handle any errors here.
37+
// Check for and handle any errors here.
3738

38-
console.error(err.message);
39-
return;
40-
}
41-
res.writeHead(200, {'content-type': 'text/plain'});
42-
res.write('received upload:\n\n');
39+
console.error(err.message);
40+
return;
41+
}
42+
res.writeHead(200, {'content-type': 'text/plain'});
43+
res.write('received upload:\n\n');
4344

44-
// This last line responds to the form submission with a list of the parsed data and files.
45+
// This last line responds to the form submission with a list of the parsed data and files.
4546

46-
res.end(util.inspect({fields: fields, files: files}));
47-
});
48-
return;
49-
}
47+
res.end(util.inspect({fields: fields, files: files}));
48+
});
49+
return;
50+
}
5051

51-
// If this is a regular request, and not a form submission, then send the form.
52+
// If this is a regular request, and not a form submission, then send the form.
5253

53-
res.writeHead(200, {'content-type': 'text/html'});
54-
res.end(
55-
'<form action="/upload" enctype="multipart/form-data" method="post">'+
56-
'<input type="text" name="title"><br>'+
57-
'<input type="file" name="upload" multiple="multiple"><br>'+
58-
'<input type="submit" value="Upload">'+
59-
'</form>'
60-
);
61-
}).listen(8080);
54+
res.writeHead(200, {'content-type': 'text/html'});
55+
res.end(
56+
'<form action="/upload" enctype="multipart/form-data" method="post">'+
57+
'<input type="text" name="title"><br>'+
58+
'<input type="file" name="upload" multiple="multiple"><br>'+
59+
'<input type="submit" value="Upload">'+
60+
'</form>'
61+
);
62+
}).listen(8080);
63+
```
6264

6365
Try it out for yourself - it's definitely the simpler solution, and `node-formidable` is a battle-hardened, production-ready library. Let userland solve problems like this for you, so that you can get back to writing the rest of your code!

0 commit comments

Comments
 (0)