KScript 문서
KO

언어

영어에서 자동 번역되었습니다. 원문은 영어입니다.

markdown 필드와 메서드

필드는 값에 관한 단순한 정보로, 대괄호 없이 점으로 읽어요: $value.name. 메서드는 인수를 받거나 작업을 수행하며, ->로 호출하거나 $value->name(arguments)처럼 값을 파이프로 넘겨서 호출해요: $value |> name(arguments).

필드

필드타입설명
.extensionstring점 없이 나타낸 원본 파일 확장자예요.
.textstring감싸진 값의 원본 텍스트예요.

KScript.Document에서 가져옴

이 항목에는 <import package="KScript.Document" />import KScript.Document가 필요합니다. KScript.Document를 참고하세요.

#markdown->find(text: string) → number KScript.Document

문서 소스에서 리터럴이 처음 일치하는 위치의 0부터 시작하는 오프셋이며, 없으면 -1입니다.
매개변수받는 값
text 필수string
예시
<let name="notes" value="```markdown
  # Notes

  Some *ideas* for the launch.
  ```" />
<echo>{ $notes->find('ideas') }</echo>
$notes = ```markdown
  # Notes

  Some *ideas* for the launch.
  ```
echo $notes->find('ideas')

#markdown->insert(content, at?: int) → markdown KScript.Document

같은 형식의 텍스트나 원본을 0부터 시작하는 오프셋 위치에 넣은 복사본을 반환해요. 오프셋을 생략하면 끝에 추가해요.
매개변수받는 값
content 필수모든 값
at 선택int

인수는 이름을 붙여 전달할 수 있습니다: ->insert(…, at: …).

예시
<let name="notes" value="```markdown
  # Notes

  Some *ideas* for the launch.
  ```" />
<echo>{ $notes->insert(' More soon.').text }</echo>
$notes = ```markdown
  # Notes

  Some *ideas* for the launch.
  ```
echo $notes->insert(' More soon.').text

#markdown->pages() → number KScript.Document

PDF에 있는 페이지 수입니다.
예시
<let name="notes" value="```markdown
  # Notes

  Some *ideas* for the launch.
  ```" />
<echo>{ $notes->pages() } pages</echo>
$notes = ```markdown
  # Notes

  Some *ideas* for the launch.
  ```
echo "{ $notes->pages() } pages"

#markdown->replace(search: string, replacement: string) → markdown KScript.Document

리터럴 일치 항목을 모두 바꾼 복사본을 반환해요.
매개변수받는 값
search 필수string
replacement 필수string

인수는 이름을 붙여 전달할 수 있습니다: ->replace(…, replacement: …).

예시
<let name="notes" value="```markdown
  # Notes

  Some *ideas* for the launch.
  ```" />
<echo>{ $notes->replace('ideas', 'plans').text }</echo>
$notes = ```markdown
  # Notes

  Some *ideas* for the launch.
  ```
echo $notes->replace('ideas', 'plans').text

#markdown->save(path: string, as?: pdf|docx|'latex'|'markdown'|html) KScript.Document

문서를 파일로 씁니다. 파일 확장자(또는 as:)가 형식을 정합니다: .md는 원본을 그대로 두고, .pdf, .docx, .tex, .html이면 렌더링합니다. 확장자가 없으면 .md입니다.
매개변수받는 값
path 필수string
as 선택다음 단어 중 하나: pdf|docx|'latex'|'markdown'|html

인수는 이름을 붙여 전달할 수 있습니다: ->save(…, as: …).

예시
<let name="notes" value="```markdown
  # Notes

  Some *ideas* for the launch.
  ```" />
<do>$notes->save('notes.pdf')</do>
<do>$notes->save('notes.docx')</do>
$notes = ```markdown
  # Notes

  Some *ideas* for the launch.
  ```
$notes->save('notes.pdf')
$notes->save('notes.docx')

#markdown->words() → number KScript.Document

텍스트에 수학 기호와 코드를 제외하고 단어가 몇 개인지 나타냅니다.
예시
<let name="notes" value="```markdown
  # Notes

  Some *ideas* for the launch.
  ```" />
<echo>{ $notes->words() } words</echo>
$notes = ```markdown
  # Notes

  Some *ideas* for the launch.
  ```
echo "{ $notes->words() } words"

any의 메서드