본문 바로가기
C.W.K.
Stream
Lesson 07 of 08 · published

코드 — inline 과 fenced block

~10 min · markdown, code, syntax-highlighting

Level 0평문
0 XP0/64 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

코드 마크업 세 가지

인라인 코드 는 백틱 하나로 감싸: `console.log()`. 감쌀 코드 안에 이미 백틱이 들어 있으면 백틱을 두 개씩 써: ``code with `backticks` inside``.

Fenced code block 은 백틱 세 개로 열고, 원하면 뒤에 언어 식별자를 붙여:

```python
def greet(name):
    return f"Hello, {name}!"
```

들여쓰기 코드 블록 (4 칸이나 탭 하나) 은 옛날 스타일이야. 언어를 알려줄 수도 없고 실수로 깨지기도 쉬우니까 fenced 를 써.

중요한 언어 식별자

자주 쓰는 건 이 정도야. python, javascript/js, typescript/ts, bash/shell, json, yaml, toml, html, css, sql, rust, go, java, c, cpp, diff, mermaid. 렌더러는 대부분 이 값을 보고 syntax highlighting 테마를 골라.

코드 안에 백틱 세 개가 있으면 ~~~ 를 써: 대체 fence (~~~) 로 감싸면 백틱을 하나하나 escape 하지 않고도 백틱 든 Markdown 을 코드 블록에 통째로 넣을 수 있어.

Code

인라인 코드·markdown
Use the `console.log()` function.
Double backticks for ``code with `backticks` inside``.
Fenced block + 언어·markdown
```python
def greet(name):
    return f"Hello, {name}!"
```

```bash
curl -s https://api.example.com | jq .
```
Tilde fence (코드에 ``` 들었을 때)·markdown
~~~markdown
This fenced block can contain ```triple backticks``` literally.
~~~

External links

Exercise

이번 주에 쓴 코드 스니펫을 하나 골라서 Markdown 파일에 세 가지 방식으로 넣어봐. 인라인으로 한 번, 들여쓰기 블록으로 한 번, 언어 식별자를 제대로 붙인 fenced block 으로 한 번. 렌더링해서 나란히 비교하고, 앞으로 기본으로 쓸 걸 하나 정해.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.