KScript ドキュメント
JA

言語

英語から自動翻訳されています。原文は英語です。

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 のメソッド