Confluence 5.3 のサポートは終了しています。
ドキュメントの最新バージョンを確認してください。
The Code Block macro allows you to display source code in your document with the appropriate syntax highlighting. The code block displays on the page as shown below:
public static void main(String[] args)
{
System.out.println("Hello World!");
}
Using the Code Block Macro
コード ブロック マクロをページに追加するには、次の手順を実行します。
オートコンプリートでマクロを素早く入力する方法 既存のマクロを編集する方法: マクロのプレースホルダをクリックして、[編集] を選択します。マクロのパラメータが編集可能な場合、マクロのダイアログ ウィンドウが開きます。
You type the code block directly into the macro placeholder in the editor. Note that any white space contained in the placeholder is not manipulated in any way by the Code Block macro. This is to provide the writer with flexibility over code indentation.
パラメーター
パラメータは、マクロ出力の内容や形式を制御するために設定するオプションです。
パラメーター | 既定 | 説明 |
|---|---|---|
Syntax highlighting | java | 構文をハイライトする言語(または環境)を特定します。既定値は java ですが、下記の言語/環境から選択可能です。
|
タイトル | なし | コードブロックにタイトルを追加します。指定すると、コードブロックの先頭行のヘッダーに表示されます。 |
折りたたむ | false | 選択すると、コード マクロの内容が、アクセス時やリフレッシュ時に折りたたまれます。 |
行番号を表示 | false | 選択すると、コード行の左側に数字が表示されます。 |
最初の行番号 | 1 | 行数を表示を選択すると、この値を最初の行の数字として定義します。 |
テーマ | 既定 | コードブロックの表示に使用するカラーテーマを指定します。テーマの多くは人気の統合開発環境 (IDE)のデフォルトのカラースキームをベースにしています。 既定のテーマConfluence (Default) は、ブランクの背景にブラックとカラーフォントの一般的なものですが、下記の人気のテーマから他のテーマを選択することも可能です。
|
Configuring the Code Block macro
You can configure the Code Block macro to use a specific language and theme by default and also upload new lanuages. You need Confluence Administrator permissions to change the default theme and language and System Administrator permissions to upload new languages.
サイトにコードブロックの既定の外観を設定するには:
- Choose the cog icon at top right of the screen, then choose Confluence Admin.
- Choose Configure Code Macro.
- [既定のテーマ] と [既定の言語] を選択します。
- 保存を選択します 。
他を指定していない限り、すべての新しいコードブロックに既定のテーマと言語が適用されます。既存のコードブロックは変更されません。
他の言語を追加するには:
- Choose the cog icon at top right of the screen, then choose Confluence Admin.
- Choose Configure Code Macro.
- Choose Add a new language.
- Locate your language file and enter a Name for the new language (this will appear when selecting the language).
- 追加を選択します。
Language files must be correctly formatted JavaScript files and adhere to the Custom Brush syntax. You can find some examples of language files here.
インストールした言語を無効化または削除するには:
- Choose the cog icon at top right of the screen, then choose Confluence Admin.
- アドオンの管理を選択します。
- Go to User-installed Add-ons and locate the add-on for your uploaded language - it will appear like this 'Custom Code Macro Highlighting for...'
- Choose Uninstall or Disable.
言語がコードマクロに表示されなくなります。
コードの例
参照先:

