Skip to content

Commit a67d8cb

Browse files
committed
style: use consistent code example language markers
1 parent 34d8cfc commit a67d8cb

File tree

100 files changed

+439
-439
lines changed

Some content is hidden

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

100 files changed

+439
-439
lines changed

sources/academy/glossary/concepts/css_selectors.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@ Some of the most common types of CSS selectors are:
1717

1818
This is used to select elements by their tag name. For example, to select all `<p>` elements, you would use the `p` selector.
1919

20-
```js
20+
```javascript
2121
const paragraphs = document.querySelectorAll('p');
2222
```
2323

2424
### Class selector
2525

2626
This is used to select elements by their class attribute. For example, to select all elements with the class of `highlight`, you would use the `.highlight` selector.
2727

28-
```js
28+
```javascript
2929
const highlightedElements = document.querySelectorAll('.highlight');
3030
```
3131

3232
### ID selector
3333

3434
This is used to select an element by its `id` attribute. For example, to select an element with the id of `header`, you would use the `#header` selector.
3535

36-
```js
36+
```javascript
3737
const header = document.querySelector(`#header`);
3838
```
3939

4040
### Attribute selector
4141

4242
This is used to select elements based on the value of an attribute. For example, to select all elements with the attribute `data-custom` whose value is `yes`, you would use the `[data-custom="yes"]` selector.
4343

44-
```js
44+
```javascript
4545
const customElements = document.querySelectorAll('[data-custom="yes"]');
4646
```
4747

4848
### Chaining selectors
4949

5050
You can also chain multiple selectors together to select elements more precisely. For example, to select an element with the class `highlight` that is inside a `<p>` element, you would use the `p.highlight` selector.
5151

52-
```js
52+
```javascript
5353
const highlightedParagraph = document.querySelectorAll('p.highlight');
5454
```
5555

sources/academy/glossary/concepts/html_elements.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ You can also add **attributes** to an element to provide additional information
1919

2020
In JavaScript, you can use the **DOM** (Document Object Model) to interact with elements on a web page. For example, you can use the [`querySelector()` method](./querying_css_selectors.md) to select an element by its [CSS selector](./css_selectors.md), like this:
2121

22-
```js
22+
```javascript
2323
const myElement = document.querySelector('#myId');
2424
```
2525

2626
You can also use `getElementById()` method to select an element by its `id`, like this:
2727

28-
```js
28+
```javascript
2929
const myElement = document.getElementById('myId');
3030
```
3131

3232
You can also use `getElementsByTagName()` method to select all elements of a certain type, like this:
3333

34-
```js
34+
```javascript
3535
const myElements = document.getElementsByTagName('p');
3636
```
3737

sources/academy/glossary/concepts/querying_css_selectors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ slug: /concepts/querying-css-selectors
1111

1212
Here's an example of how you can use it:
1313

14-
```js
14+
```javascript
1515
const firstButton = document.querySelector('button');
1616
```
1717

@@ -21,15 +21,15 @@ This will select the first button element on the page and store it in the variab
2121

2222
Here's an example of how you can use it:
2323

24-
```js
24+
```javascript
2525
const buttons = document.querySelectorAll('button');
2626
```
2727

2828
This will select all button elements on the page and store them in the variable "buttons".
2929

3030
Both functions can be used to access and manipulate the elements in the web page. Here's an example on how you can use it to extract the text of all buttons.
3131

32-
```js
32+
```javascript
3333
const buttons = document.querySelectorAll('button');
3434
const buttonTexts = buttons.forEach((button) => button.textContent);
3535
```

sources/academy/platform/deploying_your_code/input_schema.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Though writing an [input schema](/platform/actors/development/actor-definition/i
1919

2020
In the root of our project, we'll create a file named **INPUT_SCHEMA.json** and start writing the first part of the schema.
2121

22-
```json
22+
```javascripton
2323
{
2424
"title": "Adding actor input",
2525
"description": "Add all values in list of numbers with an arbitrary length.",
@@ -34,7 +34,7 @@ The **title** and **description** simply describe what the input schema is for,
3434

3535
In order to define all of the properties our actor is expecting, we must include them within an object with a key of **properties**.
3636

37-
```json
37+
```javascripton
3838
{
3939
"title": "Adding actor input",
4040
"description": "Add all values in list of numbers with an arbitrary length.",
@@ -55,7 +55,7 @@ Each property's key corresponds to the name we're expecting within our code, whi
5555

5656
Within our new **numbers** property, there are two more fields we must specify. Firstly, we must let the platform know that we're expecting an array of numbers with the **type** field. Then, we should also instruct Apify on which UI component to render for this input property. In our case, we have an array of numbers, which means we should use the **json** editor type that we discovered in the ["array" section](/platform/actors/development/actor-definition/input-schema#array) of the input schema documentation. We could also use **stringList**, but then we'd have to parse out the numbers from the strings.
5757

58-
```json
58+
```javascripton
5959
{
6060
"title": "Adding actor input",
6161
"description": "Add all values in list of numbers with an arbitrary length.",
@@ -76,7 +76,7 @@ Within our new **numbers** property, there are two more fields we must specify.
7676

7777
The great thing about building an input schema is that it will automatically validate your inputs based on their type, maximum value, minimum value, etc. Sometimes, you want to ensure that the user will always provide input for certain fields, as they are crucial to the actor's run. This can be done by using the **required** field and passing in the names of the fields you'd like to require.
7878

79-
```json
79+
```javascripton
8080
{
8181
"title": "Adding actor input",
8282
"description": "Add all values in list of numbers with an arbitrary length.",

sources/academy/platform/deploying_your_code/inputs_outputs.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ npm install apify
3939

4040
Now, let's import `Actor` from `apify` and use the `Actor.getInput()` function to grab our input.
4141

42-
```js
42+
```javascript
4343
// index.js
4444
import { Actor } from 'apify';
4545

@@ -59,15 +59,15 @@ If we run this right now, we'll see **null** in our terminal - this is because w
5959

6060
We'll now add an **INPUT.json** file within **storage/key_value_stores/default** to match what we're expecting in our code.
6161

62-
```json
62+
```javascripton
6363
{
6464
"numbers": [5, 5, 5, 5]
6565
}
6666
```
6767

6868
Then we can add our example project code from earlier. It will grab the input and use it to generate a solution which is logged into the console.
6969

70-
```js
70+
```javascript
7171
// index.js
7272
import { Actor } from 'apify';
7373

@@ -137,7 +137,7 @@ Similarly to reading input, you can write the actor's output either by using the
137137

138138
In the SDK, we can write to the dataset with the `Actor.pushData()` function. Let's go ahead and write the solution of the `addAllNumbers()` function to the dataset store using this function:
139139

140-
```js
140+
```javascript
141141
// index.js
142142

143143
// This is our example project code from earlier.
@@ -213,7 +213,7 @@ Since we've changed our code a lot from the way it originally was by wrapping it
213213

214214
After running our script, there should be a single item in the default dataset that looks like this:
215215

216-
```json
216+
```javascripton
217217
{
218218
"solution": 20
219219
}

sources/academy/platform/deploying_your_code/output_schema.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Firstly, create a `.actor` folder in the root of your actor's source code. Then,
2525

2626
Next, copy-paste the following template code into your `actor.json` file.
2727

28-
```json
28+
```javascripton
2929
{
3030
"actorSpecification": 1,
3131
"name": "___ENTER_ACTOR_NAME____",
@@ -73,7 +73,7 @@ To configure the output schema, simply replace the fields in the template with t
7373

7474
For reference, you can use the [Zappos Scraper source code](https://github.com/PerVillalva/zappos-scraper-actor/blob/main/.actor/actor.json) as an example of how the final implementation of the output tab should look in a live actor.
7575

76-
```json
76+
```javascripton
7777
{
7878
"actorSpecification": 1,
7979
"name": "zappos-scraper",
@@ -145,7 +145,7 @@ Also, if your desired label has the same name as the defined object key, then yo
145145

146146
The matching object for the Zappos Scraper shown in the example above will look something like this:
147147

148-
```js
148+
```javascript
149149
const results = {
150150
url: request.loadedUrl,
151151
imgUrl: $('#stage button[data-media="image"] img[itemprop="image"]').attr('src'),

sources/academy/platform/expert_scraping_with_apify/apify_api_and_client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Though it's a bit unintuitive, this is a perfect activity for learning how to us
3939

4040
The new actor should take the following input values, which be mapped to parameters in the API calls:
4141

42-
```json
42+
```javascripton
4343
{
4444
// How much memory to allocate to the Amazon actor
4545
// Must be a power of 2

sources/academy/platform/expert_scraping_with_apify/migrations_maintaining_state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Before moving forward, read about actor [events](/sdk/js/docs/upgrading/upgradin
3535

3636
Once again returning to our Amazon **demo-actor**, let's say that we need to store an object in memory (as a variable) containing all of the scraped ASINs as keys and the number of offers scraped from each ASIN as values. The object should follow this format:
3737

38-
```json
38+
```javascripton
3939
{
4040
"B079ZJ1BPR": 3,
4141
"B07D4R4258": 21

sources/academy/platform/expert_scraping_with_apify/saving_useful_stats.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Before moving on, give these valuable resources a quick lookover:
3636

3737
In our Amazon actor, each dataset result must now have the following extra keys:
3838

39-
```json
39+
```javascripton
4040
{
4141
"dateHandled": "date-here", // the date + time at which the request was handled
4242
"numberOfRetries": 4, // the number of retries of the request before running successfully
@@ -46,7 +46,7 @@ In our Amazon actor, each dataset result must now have the following extra keys:
4646

4747
Also, an object including these values should be persisted during the run in th Key-Value store and logged to the console every 10 seconds:
4848

49-
```json
49+
```javascripton
5050
{
5151
"errors": { // all of the errors for every request path
5252
"some-site.com/products/123": [

sources/academy/platform/expert_scraping_with_apify/solutions/handling_migrations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Let's first head into our **demo-actor** and create a new file named **asinTrack
1515

1616
Here's the skeleton of our class:
1717

18-
```js
18+
```javascript
1919
// asinTracker.js
2020
class ASINTracker {
2121
constructor() {
@@ -48,7 +48,7 @@ Multiple techniques exist for storing data in memory; however, this is the most
4848

4949
Here is our updated **routes.js** file which is now utilizing this utility class to track the number of offers for each product ASIN:
5050

51-
```js
51+
```javascript
5252
// routes.js
5353
import { createCheerioRouter } from '@crawlee/cheerio';
5454
import { BASE_URL, OFFERS_URL, labels } from './constants';
@@ -131,7 +131,7 @@ The **persistState** event is automatically fired (by default) every 60 seconds
131131

132132
In order to persist our ASIN tracker object, let's use the `Actor.on` function to listen for the **persistState** event and store it in the key-value store each time it is emitted.
133133

134-
```js
134+
```javascript
135135
// asinTracker.js
136136
import { Actor } from 'apify';
137137
// We've updated our constants.js file to include the name
@@ -168,7 +168,7 @@ Great! Now our state will be persisted every 60 seconds in the key-value store.
168168

169169
In order to fix this, let's create a method called `initialize` which will be called at the very beginning of the actor's run, and will check the key-value store for a previous state under the key **ASIN-TRACKER**. If a previous state does live there, then it will update the class' `state` variable with the value read from the key-value store:
170170

171-
```js
171+
```javascript
172172
// asinTracker.js
173173
import { Actor } from 'apify';
174174
import { ASIN_TRACKER } from './constants';
@@ -209,7 +209,7 @@ module.exports = new ASINTracker();
209209

210210
We'll now call this function at the top level of the **main.js** file to ensure it is the first thing that gets called when the actor starts up:
211211

212-
```js
212+
```javascript
213213
// main.js
214214

215215
// ...

0 commit comments

Comments
 (0)