이 문서는 https://tiddlywiki.com/languages/ko-KR/에서 티들리위키의 정적 HTML 표현의 일부입니다

CodeBlockWidget

2024년 8월 9일 오전 7:46

Introduction

The codeblock widget renders text in <pre> and <code> blocks, causing it to be displayed monospace. A language may optionally be specified using the language attribute, however syntax highlighting will only be used if the Highlight Plugin is installed.

Content and Attributes

The content of the <$codeblock> widget is ignored.

AttributeDescription
codeContents of the block to render as code
languageProgramming language for syntax highlighting

The language attribute accepts either:

Examples

Here is an example embedding the contents of a tiddler as a code block.

<$codeblock code={{$:/editions/tw5.com/macro-examples/say-hi}} />

That renders as:

\define sayhi(name:"Bugs Bunny",address:"Rabbit Hole Hill")
Hi, I'm $name$ and I live in $address$.
\end

A codeblock may also specify a language.

<$codeblock code="SELECT * FROM users WHERE deleted = false" language="sql" />

That renders as:

SELECT * FROM users WHERE deleted = false