소스 코드

문서개요

이 문서는 AsciiDoc 에서 소스 코드 를 표현하는 방법에 대해 설명합니다.

1. Source Code

문서에서 소스 코드를 표현하기 위해서는 [source,언어명]와 소스 블록(----)을 사용하고 결과물은 다음과 같다.

AsciiDoc에서 특수하게 사용되는 문자가 포함된 경우 "텍스트 그대로 출력"을 참고한다.

1.1. AsciiDoc 소스

소스 코드를 작성하는 AsciiDoc 소스는 다음과 같다.

[source,c]
----
#include <stdio.h>
int main() {
    printf("Hello, World!");
    return 0;
}
----

1.2. 결과

소스 코드를 사용하는 경우 본문 형태는 다음과 같다.

#include <stdio.h>
int main() {
    printf("Hello, World!");
    return 0;
}

2. Stack Trace

문서에서 Stack Trace를 표현하기 위해서는 [%collapsible]와 블록(====)을 사용하고 결과물은 다음과 같다.

2.1. AsciiDoc 소스

Stack Trace를 작성하는 AsciiDoc 소스 다음과 같다.

.Show stacktrace
[%collapsible]
====
[source]
----
Error: Content repository not found (url: https://git.example.org/repo.git)
    at transformGitCloneError
    at git.clone.then.then.catch
Caused by: HttpError: HTTP Error: 401 HTTP Basic: Access Denied
    at GitCredentialManagerStore.rejected
    at fill.then
----
====

2.2. 결과

Stack Trace를 사용하는 경우 본문 형태는 다음과 같다.

Show stacktrace
Error: Content repository not found (url: https://git.example.org/repo.git)
    at transformGitCloneError
    at git.clone.then.then.catch
Caused by: HttpError: HTTP Error: 401 HTTP Basic: Access Denied
    at GitCredentialManagerStore.rejected
    at fill.then

3. 텍스트 그대로 출력

입력한 대로 출력 텍스트를 표시한다.

  • 인라인 패스 매크로: 인라인일 경우 사용한다.

  • 리터럴 블록: 블록으로 지정할 때 사용한다.

3.1. 인라인 패스 매크로 (pass:[ ])

인라인 텍스트의 서식이 지정되지 않도록 하는 특수 구문이다.

3.1.1. AsciiDoc 소스

Inline pass를 작성하는 AsciiDoc 소스 다음과 같다.

[source,java]
----
protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
            **.antMatchers("/resources/pass:[**]").permitAll()**
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .loginPage("/login")
            .permitAll();
----

3.1.2. 결과

Inline pass를 사용하는 경우 본문 형태는 다음과 같다.

protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
            **.antMatchers("/resources/pass:[**]").permitAll()**
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .loginPage("/login")
            .permitAll();

3.2. 리터럴 블록 (....)

리터럴 블록은 소스에서 보는 그대로 작성한 텍스트를 표시한다.

3.2.1. AsciiDoc 소스

Literal Block을 작성하는 AsciiDoc 소스 다음과 같다.

....
Kismet: Where is the *defensive operations manual*?

Computer: Calculating ...
Can not locate object.
....

3.2.2. 결과

Literal Block을 사용하는 경우 본문 형태는 다음과 같다.

Kismet: Where is the *defensive operations manual*?

Computer: Calculating ...
Can not locate object.
  1. 출력에서 텍스트에 굵은 텍스트 서식이 적용되지 않는다.

  2. 세 개의 연속된 마침표가 줄임표 유니코드 문자로 대체되지 않는다.