Skip to content

Commit edcc8eb

Browse files
committed
Merge pull request github#865 from Shredder121/terminal-blocks
Document alternative .terminal block syntax
2 parents 840aad7 + 125da4d commit edcc8eb

40 files changed

+640
-680
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,28 @@ Some actions return arrays. You can modify the JSON by passing a block:
7777

7878
### Terminal blocks
7979

80-
You can specify terminal blocks with `pre.terminal` elements. (It'd be nice if
81-
Markdown could do this more cleanly.)
80+
You can specify terminal blocks by prefacing a [block element][block boundaries] with `{:.terminal}`.
81+
82+
```markdown
83+
{:.terminal}
84+
$ curl foobar
85+
```
86+
87+
Alternatively, you can use plain html and use `pre.terminal` elements.
88+
(If, for example, you need to emphasis text with `<em>`)
8289

8390
```html
8491
<pre class="terminal">
85-
$ curl foobar
92+
$ curl <em>foobar<em>
8693
....
8794
</pre>
8895
```
8996

9097
This is not a `curl` tutorial though. Not every API call needs
9198
to show how to access it with `curl`.
9299

100+
[block boundaries]: http://kramdown.gettalong.org/syntax.html#block-boundaries
101+
93102
## Development
94103

95104
Nanoc compiles the site into static files living in `./output`. It's

content/changes/2012-10-24-set-default-branch.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
Now, you can update this setting via the API. We've added a `default_branch` parameter to the [Edit Repository method][edit-repo]:
1313

14-
<pre class="terminal">
15-
curl -u pengwynn \
16-
-d '{"name": "octokit", "default_branch":"development"}' \
17-
https://api.github.com/repos/octokit/octokit.rb
18-
</pre>
14+
{:.terminal}
15+
curl -u pengwynn \
16+
-d '{"name": "octokit", "default_branch":"development"}' \
17+
https://api.github.com/repos/octokit/octokit.rb
1918

2019
If you provide a branch name that hasn't been pushed to GitHub, we'll gracefully fall back to `'master'` or the first branch.
2120

content/changes/2012-10-26-notifications-api.md

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,50 @@ view and mark notifications as read.
1717
The core notifications functionality is under the `/notifications` endpoint.
1818
You can look for unread notifications:
1919

20-
<pre class="terminal">
21-
$ curl https://api.github.com/notifications
22-
</pre>
20+
{:.terminal}
21+
$ curl https://api.github.com/notifications
2322

2423
You can filter these notifications to a single Repository:
2524

26-
<pre class="terminal">
27-
$ curl https://api.github.com/repos/technoweenie/faraday/notifications
28-
</pre>
25+
{:.terminal}
26+
$ curl https://api.github.com/repos/technoweenie/faraday/notifications
2927

3028
You can mark them as read:
3129

32-
<pre class="terminal">
33-
# all notifications
34-
$ curl https://api.github.com/notifications \
35-
-X PUT -d '{"read": true}'
30+
{:.terminal}
31+
# all notifications
32+
$ curl https://api.github.com/notifications \
33+
-X PUT -d '{"read": true}'
3634

37-
# notifications for a single repository
38-
$ curl https://api.github.com/repos/technoweenie/faraday/notifications \
39-
-X PUT -d '{"read": true}'
40-
</pre>
35+
# notifications for a single repository
36+
$ curl https://api.github.com/repos/technoweenie/faraday/notifications \
37+
-X PUT -d '{"read": true}'
4138

4239
You can also modify subscriptions for a Repository or a single thread.
4340

44-
<pre class="terminal">
45-
# subscription details for the thread (either an Issue or Commit)
46-
$ curl https://api.github.com/notifications/threads/1/subscription
41+
{:.terminal}
42+
# subscription details for the thread (either an Issue or Commit)
43+
$ curl https://api.github.com/notifications/threads/1/subscription
4744

48-
# subscription details for a whole Repository.
49-
$ curl https://api.github.com/repos/technoweenie/faraday/subscription
50-
</pre>
45+
# subscription details for a whole Repository.
46+
$ curl https://api.github.com/repos/technoweenie/faraday/subscription
5147

5248
## Polling
5349

5450
The Notifications API is optimized for polling by the last modified time:
5551

56-
<pre class="terminal">
57-
# Add authentication to your requests
58-
$ curl -I https://api.github.com/notifications
59-
HTTP/1.1 200 OK
60-
Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT
61-
X-Poll-Interval: 60
62-
63-
# Pass the Last-Modified header exactly
64-
$ curl -I https://api.github.com/notifications
65-
-H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT"
66-
HTTP/1.1 304 Not Modified
67-
X-Poll-Interval: 60
68-
</pre>
52+
{:.terminal}
53+
# Add authentication to your requests
54+
$ curl -I https://api.github.com/notifications
55+
HTTP/1.1 200 OK
56+
Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT
57+
X-Poll-Interval: 60
58+
59+
# Pass the Last-Modified header exactly
60+
$ curl -I https://api.github.com/notifications
61+
-H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT"
62+
HTTP/1.1 304 Not Modified
63+
X-Poll-Interval: 60
6964

7065
You can read about the API details in depth in the [Notifications documentation][api].
7166

content/changes/2012-11-27-forking-to-organizations.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
We made a slight change to the way you fork a repository. By default, you
99
can fork my repository through an HTTP POST to the repository's fork resource.
1010

11+
{:.terminal}
1112
$ curl -X POST https://api.github.com/repos/technoweenie/faraday/forks
1213

1314
This repository forks to your personal account. However, there are cases when
1415
you want to fork to one of your organizations instead. The previous method
1516
required a `?org` query parameter:
1617

18+
{:.terminal}
1719
$ curl -X POST /repos/technoweenie/faraday/forks?org=mycompany
1820

1921
Query parameters on POST requests are unusual in APIs, and definitely
2022
inconsistent with the rest of the GitHub API. You should be able to post a
2123
JSON body like every other POST endpoint. Now, you can! Only, now we're
2224
calling the field `organization`.
2325

26+
{:.terminal}
2427
$ curl /repos/technoweenie/faraday/forks?org=mycompany \
2528
-d '{"organization": "mycompany"}'
2629

content/changes/2012-11-29-gitignore-templates.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
The [Gitignore Templates API][new-api] makes it easy to list those templates:
1414

15+
{:.terminal}
1516
curl https://api.github.com/gitignore/templates
1617

1718
HTTP/1.1 200 OK
@@ -28,6 +29,7 @@
2829

2930
If you'd like to view the source, you can also fetch a single template.
3031

32+
{:.terminal}
3133
curl -H 'Accept: application/vnd.github.raw' \
3234
https://api.github.com/gitignore/templates/Objective-C
3335

content/changes/2012-12-04-List-comments-for-repo.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Today, we're introducing two new methods to grab all Issue Comments and Review
1313
Comments for a repository.
1414

15+
{:.terminal}
1516
# Grab all Issue Comments
1617
curl https://api.github.com/repos/mathiasbynens/dotfiles/issues/comments
1718

content/changes/2012-12-06-create-authorization-for-app.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
authorization using Basic Auth. Just POST your desired scopes and optional
1010
note and you get a token back:
1111

12-
<pre class='terminal'>
12+
{:.terminal}
1313
curl -u pengwynn -d '{"scopes": ["user", "gist"]}' \
1414
https://api.github.com/authorizations
15-
</pre>
1615

1716
This call creates a token for the authenticated user tied to a special "API"
1817
OAuth application.
@@ -22,14 +21,13 @@
2221
the settings page for your OAuth application.
2322

2423

25-
<pre class='terminal'>
24+
{:.terminal}
2625
curl -u pengwynn -d '{ \
2726
"scopes": ["user", "gist"], \
2827
"client_id": "abcdeabcdeabcdeabcdeabcde" \
2928
"client_secret": "abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde" \
3029
}' \ '
3130
https://api.github.com/authorizations
32-
</pre>
3331

3432
No more implementing the [web flow][web-flow] just to get a token tied to your
3533
app's rate limit.

content/changes/2012-12-08-finding-source-and-fork-repos-for-organizations.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
which are forks of another repository, as well as those repositories which
1212
are sources (not forks).
1313

14+
{:.terminal}
1415
# Grab all fork Repositories for an Organization
1516
curl "https://api.github.com/orgs/:org/repos?type=forks"
1617

content/changes/2012-12-10-Diff-and-patch-media-types.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
Simply use the same resource URL and send either `application/vnd.github.diff` or `application/vnd.github.patch` in the `Accept` header:
1515

16+
{:.terminal}
1617
curl -H "Accept: application/vnd.github.diff" https://api.github.com/repos/pengwynn/dotfiles/commits/aee60a4cd56fb4c6a50e60f17096fc40c0d4d72c
1718

1819
diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink

content/changes/2012-9-28-auto-init-for-repositories.html

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
Now you can optionally init a repository when it's created by sending `true`
1414
for the `auto_init` parameter:
1515

16-
<pre class="terminal">
17-
curl -i -u pengwynn \
18-
-d '{"name": "create-repo-test", "auto_init": true}' \
19-
https://api.github.com/user/repos
20-
</pre>
16+
{:.terminal}
17+
curl -i -u pengwynn \
18+
-d '{"name": "create-repo-test", "auto_init": true}' \
19+
https://api.github.com/user/repos
2120

2221
The resulting repository will have a README stub and an initial commit.
2322

@@ -29,12 +28,11 @@
2928
the basename of any template in the [GitHub gitignore templates
3029
project](https://github.com/github/gitignore).
3130

32-
<pre class="terminal">
33-
curl -i -u pengwynn \
34-
-d '{"name": "create-repo-test", "auto_init": true, \
35-
"gitignore_template": "Haskell"}' \
36-
https://api.github.com/user/repos
37-
</pre>
31+
{:.terminal}
32+
curl -i -u pengwynn \
33+
-d '{"name": "create-repo-test", "auto_init": true, \
34+
"gitignore_template": "Haskell"}' \
35+
https://api.github.com/user/repos
3836

3937

4038
As the [docs point out](/v3/repos/#create), the `gitignore_template` parameter

content/changes/2012-9-5-watcher-api.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
can be verified by checking the `X-GitHub-Media-Type` header on all API
5454
responses.
5555

56+
{:.terminal}
5657
# Accesses a user's starred repositories.
5758
curl https://api.github.com/user/watched \
5859
-H "Accept: application/vnd.github.beta+json"

content/changes/2013-04-30-improved-submodule-support-in-repository-contents-api.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,25 @@ When you view a repository with a submodule on github.com, you get useful links
1111

1212
Today we're making that data available in the [Repository Contents API][docs].
1313

14-
<pre class="terminal">
15-
curl https://api.github.com/repos/jquery/jquery/contents/test/qunit
14+
{:.terminal}
15+
curl https://api.github.com/repos/jquery/jquery/contents/test/qunit
1616

17-
{
18-
"name": "qunit",
19-
"path": "test/qunit",
20-
"type": "submodule",
21-
"submodule_git_url": "git://github.com/jquery/qunit.git",
22-
"sha": "6ca3721222109997540bd6d9ccd396902e0ad2f9",
23-
"size": 0,
24-
"url": "https://api.github.com/repos/jquery/jquery/contents/test/qunit?ref=master",
25-
"git_url": "https://api.github.com/repos/jquery/qunit/git/trees/6ca3721222109997540bd6d9ccd396902e0ad2f9",
26-
"html_url": "https://github.com/jquery/qunit/tree/6ca3721222109997540bd6d9ccd396902e0ad2f9",
27-
"_links": {
28-
"self": "https://api.github.com/repos/jquery/jquery/contents/test/qunit?ref=master",
29-
"git": "https://api.github.com/repos/jquery/qunit/git/trees/6ca3721222109997540bd6d9ccd396902e0ad2f9",
30-
"html": "https://github.com/jquery/qunit/tree/6ca3721222109997540bd6d9ccd396902e0ad2f9"
31-
}
32-
}
33-
</pre>
17+
{
18+
"name": "qunit",
19+
"path": "test/qunit",
20+
"type": "submodule",
21+
"submodule_git_url": "git://github.com/jquery/qunit.git",
22+
"sha": "6ca3721222109997540bd6d9ccd396902e0ad2f9",
23+
"size": 0,
24+
"url": "https://api.github.com/repos/jquery/jquery/contents/test/qunit?ref=master",
25+
"git_url": "https://api.github.com/repos/jquery/qunit/git/trees/6ca3721222109997540bd6d9ccd396902e0ad2f9",
26+
"html_url": "https://github.com/jquery/qunit/tree/6ca3721222109997540bd6d9ccd396902e0ad2f9",
27+
"_links": {
28+
"self": "https://api.github.com/repos/jquery/jquery/contents/test/qunit?ref=master",
29+
"git": "https://api.github.com/repos/jquery/qunit/git/trees/6ca3721222109997540bd6d9ccd396902e0ad2f9",
30+
"html": "https://github.com/jquery/qunit/tree/6ca3721222109997540bd6d9ccd396902e0ad2f9"
31+
}
32+
}
3433

3534
If you have any questions or feedback, please drop us a line at
3635
[support@github.com](mailto:support@github.com?subject=Submodules in Repository Contents API).

content/changes/2013-04-30-statuses-for-branches-and-tags.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ Last week we announced [support for build statuses in the branches page][blog].
99
Now we are extending this to the API. The [API endpoint for commit statuses][doc]
1010
has been extended to allow branch and tag names, as well as commit SHAs.
1111

12-
<pre class="terminal">
13-
curl https://api.github.com/repos/rails/rails/statuses/3-2-stable
14-
</pre>
12+
{:.terminal}
13+
curl https://api.github.com/repos/rails/rails/statuses/3-2-stable
1514

1615
Enjoy.
1716

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