summaryrefslogtreecommitdiff
path: root/docs/templates.md
diff options
context:
space:
mode:
authormarv <rotrobmin@gmail.com>2024-02-02 20:44:14 -0800
committerGitHub <noreply@github.com>2024-02-03 04:44:14 +0000
commit97c5c741137ecc363630c58797901f1eb829c1bb (patch)
tree050bd42fc633d728d1687d51db93714efabbfe81 /docs/templates.md
parente598a97f27747bef0f850dcce2ad7bdeab89e0cd (diff)
Add Prettier Formatting for Markdown Files and Pre-Commit Hook (#543)
* Install prettier, add prettierignore * Add precommit hook for md * Prettier format md files
Diffstat (limited to 'docs/templates.md')
-rw-r--r--docs/templates.md506
1 files changed, 294 insertions, 212 deletions
diff --git a/docs/templates.md b/docs/templates.md
index ddab4390..3f51dc98 100644
--- a/docs/templates.md
+++ b/docs/templates.md
@@ -5,7 +5,6 @@
Yomitan supports several custom Handlebars helpers for rendering templates.
The source code for these templates can be found [here](../ext/js/templates/sandbox/anki-template-renderer.js).
-
### `dumpObject`
Converts an object to a pretty-printed JSON string.
@@ -14,33 +13,38 @@ This function can be helpful for debugging values when creating templates.
<details>
<summary>Syntax:</summary>
- <code>{{dumpObject <i>object</i>}}</code>
+<code>{{dumpObject <i>object</i>}}</code>
- * _`object`_ <br>
- The object to convert.
+- _`object`_ <br>
+The object to convert.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
<pre>{{dumpObject .}}</pre>
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
<pre>{
"key": "value"
}</pre>
```
- Preview:
+Preview:
+
+<!-- prettier-ignore -->
```html
{
"key": "value"
}
```
-</details>
+</details>
### `furigana`
@@ -49,34 +53,37 @@ Converts a definition or expression/reading pair to its furigana representation.
<details>
<summary>Syntax:</summary>
- <code>{{furigana <i>definition</i>}}</code><br>
- <code>{{furigana <i>expression</i> <i>reading</i>}}</code><br>
+<code>{{furigana <i>definition</i>}}</code><br>
+<code>{{furigana <i>expression</i> <i>reading</i>}}</code><br>
- * _`definition`_ <br>
- The definition to convert.
- * _`expression`_ <br>
- The expression to convert.
- * _`reading`_ <br>
- The reading to convert.
+- _`definition`_ <br>
+ The definition to convert.
+- _`expression`_ <br>
+ The expression to convert.
+- _`reading`_ <br>
+The reading to convert.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{furigana .}}
{{furigana "読む" "よむ"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
<ruby>読<rt>よ</rt></ruby>む
```
- Preview
+Preview
+
<pre><ruby>読<rt>よ</rt></ruby>む</pre>
</details>
-
### `furiganaPlain`
Converts a definition or expression/reading pair to its simplified furigana representation.
@@ -84,30 +91,33 @@ Converts a definition or expression/reading pair to its simplified furigana repr
<details>
<summary>Syntax:</summary>
- <code>{{furiganaPlain <i>definition</i>}}</code>
- <code>{{furiganaPlain <i>expression</i> <i>reading</i>}}</code><br>
+<code>{{furiganaPlain <i>definition</i>}}</code>
+<code>{{furiganaPlain <i>expression</i> <i>reading</i>}}</code><br>
- * _`definition`_ <br>
- The definition to convert.
- * _`expression`_ <br>
- The expression to convert.
- * _`reading`_ <br>
- The reading to convert.
+- _`definition`_ <br>
+ The definition to convert.
+- _`expression`_ <br>
+ The expression to convert.
+- _`reading`_ <br>
+The reading to convert.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{~furiganaPlain .~}}
{{furiganaPlain "読む" "よむ"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
読[よ]む
```
-</details>
+</details>
### `multiLine`
@@ -116,11 +126,13 @@ Replaces newline characters with a forced HTML line break `<br>`.
<details>
<summary>Syntax:</summary>
- <code>{{#multiLine}}<i>text with multiple lines</i>{{/multiLine}}</code>
+<code>{{#multiLine}}<i>text with multiple lines</i>{{/multiLine}}</code>
+
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#multiLine~}}
some
@@ -129,16 +141,18 @@ Replaces newline characters with a forced HTML line break `<br>`.
{{~/multiLine}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
some<br>multiline<br>text
```
- Preview:
+Preview:
+
<pre>some<br>multiline<br>text</pre>
</details>
-
### `regexReplace`
Uses a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to replace a pattern with the specified text.
@@ -146,32 +160,35 @@ Uses a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScr
<details>
<summary>Syntax:</summary>
- <code>{{#regexReplace <i>regex</i> <i>replacement</i> <i>[flags]</i>}}<i>text-to-modify</i>{{/regexReplace}}</code><br>
- <code>{{regexReplace <i>regex</i> <i>replacement</i> <i>[flags]</i> <i>[text-to-modify]...</i>}}</code><br>
+<code>{{#regexReplace <i>regex</i> <i>replacement</i> <i>[flags]</i>}}<i>text-to-modify</i>{{/regexReplace}}</code><br>
+<code>{{regexReplace <i>regex</i> <i>replacement</i> <i>[flags]</i> <i>[text-to-modify]...</i>}}</code><br>
- * _`regex`_ <br>
- The raw string used to create the regular expression. This value is passed to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
- * _`replacement`_ <br>
- The text used to replace pattern matches. This supports the standard [special capture group replacements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter) as supported by the web browser.
- * _`flags`_ _(optional)_ <br>
- Optional flags to pass to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
- * _`text-to-modify`_ <br>
- The text that the regular expression is applied to.
- If multiple arguments are present, they are all concatenated.
+- _`regex`_ <br>
+ The raw string used to create the regular expression. This value is passed to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
+- _`replacement`_ <br>
+ The text used to replace pattern matches. This supports the standard [special capture group replacements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter) as supported by the web browser.
+- _`flags`_ _(optional)_ <br>
+ Optional flags to pass to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
+- _`text-to-modify`_ <br>
+The text that the regular expression is applied to.
+If multiple arguments are present, they are all concatenated.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#regexReplace "\(([^)]*)\)" "$1" "g"~}}Here is (some) (text) (in) (parentheses){{~/regexReplace}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
Here is some text in parentheses
```
-</details>
+</details>
### `regexMatch`
@@ -180,30 +197,33 @@ Uses a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScr
<details>
<summary>Syntax:</summary>
- <code>{{#regexMatch <i>regex</i> <i>[flags]</i>}}<i>text-to-modify</i>{{/regexMatch}}</code><br>
- <code>{{regexMatch <i>regex</i> <i>[flags]</i> <i>[text-to-modify]...</i>}}</code><br>
+<code>{{#regexMatch <i>regex</i> <i>[flags]</i>}}<i>text-to-modify</i>{{/regexMatch}}</code><br>
+<code>{{regexMatch <i>regex</i> <i>[flags]</i> <i>[text-to-modify]...</i>}}</code><br>
- * _`regex`_ <br>
- The raw string used to create the regular expression. This value is passed to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
- * _`flags`_ _(optional)_ <br>
- Optional flags to pass to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
- * _`text-to-modify`_ <br>
- The text that the regular expression is applied to.
- If multiple arguments are present, they are all concatenated.
+- _`regex`_ <br>
+ The raw string used to create the regular expression. This value is passed to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
+- _`flags`_ _(optional)_ <br>
+ Optional flags to pass to the [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp) constructor.
+- _`text-to-modify`_ <br>
+The text that the regular expression is applied to.
+If multiple arguments are present, they are all concatenated.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#regexMatch "\(([^)]*)\)" "g"~}}Here is (some) (text) (in) (parentheses){{~/regexMatch}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
(some)(text)(in)(parentheses)
```
-</details>
+</details>
### `mergeTags`
@@ -212,28 +232,31 @@ Creates a set of all unique tags for the definition and returns a text represent
<details>
<summary>Syntax:</summary>
- <code>{{mergeTags <i>definition</i> <i>isGroupMode</i> <i>isMergeMode</i>}}</code>
+<code>{{mergeTags <i>definition</i> <i>isGroupMode</i> <i>isMergeMode</i>}}</code>
- * _`definition`_ <br>
- The root definition object.
- * _`isGroupMode`_ _(optional)_ <br>
- Whether or not the display mode is the 'group' mode.
- * _`isMergeMode`_ <br>
- Whether or not the display mode is the 'merge' mode.
+- _`definition`_ <br>
+ The root definition object.
+- _`isGroupMode`_ _(optional)_ <br>
+ Whether or not the display mode is the 'group' mode.
+- _`isMergeMode`_ <br>
+Whether or not the display mode is the 'merge' mode.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{~mergeTags definition group merge~}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
v5m, vt, JMdict (English)
```
-</details>
+</details>
### `#eachUpTo`
@@ -243,34 +266,37 @@ If the iterable is falsy or empty, the `else` condition will be used.
<details>
<summary>Syntax:</summary>
- <code>{{#eachUpTo <i>iterable</i> <i>maxCount</i>}}<i>(modification)</i>{{else}}<i>(else-modification)</i>{{/eachUpTo}}</code>
+<code>{{#eachUpTo <i>iterable</i> <i>maxCount</i>}}<i>(modification)</i>{{else}}<i>(else-modification)</i>{{/eachUpTo}}</code>
- * _`iterable`_ <br>
- The object that should be looped over. A JavaScript [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loop is used, so the object only needs to be iterable.
- * _`maxCount`_ _(optional)_ <br>
- The maximum number of entries to loop over.
- * _`modification`_ <br>
- The template used to modify the value. The context is changed to the current item of iteration.
- * _`else-modification`_ <br>
- The template used in case the iterable is falsy or empty. The context is unchanged.
+- _`iterable`_ <br>
+ The object that should be looped over. A JavaScript [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) loop is used, so the object only needs to be iterable.
+- _`maxCount`_ _(optional)_ <br>
+ The maximum number of entries to loop over.
+- _`modification`_ <br>
+ The template used to modify the value. The context is changed to the current item of iteration.
+- _`else-modification`_ <br>
+The template used in case the iterable is falsy or empty. The context is unchanged.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{~#eachUpTo someArray 5}}{{{.}}}<br>{{else}}Empty{{/mergeTags~}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
someArray[0]<br>someArray[1]<br>someArray[2]<br>someArray[3]<br>someArray[4]<br>
```
- Preview:
+Preview:
+
<pre>someArray[0]<br>someArray[1]<br>someArray[2]<br>someArray[3]<br>someArray[4]<br></pre>
</details>
-
### `spread`
Uses the JavaScript [spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) operator to convert one or more iterables into a single array.
@@ -279,71 +305,77 @@ This allows it to be used similar to an [`Array.concat`](https://developer.mozil
<details>
<summary>Syntax:</summary>
- <code>{{spread <i>iterable1</i> <i>iterable2</i> <i>...</i> <i>iterableN</i>}}</code>
+<code>{{spread <i>iterable1</i> <i>iterable2</i> <i>...</i> <i>iterableN</i>}}</code>
- * _`iterableN`_ <br>
- A variable amount of iterable objects to combine into a single array.
+- _`iterableN`_ <br>
+A variable amount of iterable objects to combine into a single array.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#each (spread array1 array2)}}{{{.}}}<br>{{/each}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
array1[0]<br>array1[1]<br>array2[0]<br>array2[1]<br>
```
- Preview:
+Preview:
+
<pre>array1[0]<br>array1[1]<br>array2[0]<br>array2[1]<br></pre>
</details>
-
### `op`
Performs a simple operation on one, two, or three arguments. The operations available are:
-* Unary operators: `+`, `-`, `~`, `!`
-* Binary operators: `+`, `-`, `/`, `*`, `%`, `**`, `==`, `!=`, `===`, `!==`, `<`, `<=`, `>`, `>=`, `<<`, `>>`, `>>>`, `&`, `|`, `^`, `&&`, `||`
-* Ternary operators: `?:`
+- Unary operators: `+`, `-`, `~`, `!`
+- Binary operators: `+`, `-`, `/`, `*`, `%`, `**`, `==`, `!=`, `===`, `!==`, `<`, `<=`, `>`, `>=`, `<<`, `>>`, `>>>`, `&`, `|`, `^`, `&&`, `||`
+- Ternary operators: `?:`
If an unknown operator is specified, the `undefined` value is returned.
<details>
<summary>Syntax:</summary>
- <code>{{op <i>operator</i> <i>operand1</i> <i>[operand2]</i> <i>[operand3]</i>}}</code>
+<code>{{op <i>operator</i> <i>operand1</i> <i>[operand2]</i> <i>[operand3]</i>}}</code>
- * _`operator`_ <br>
- One of the unary, binary, or ternary operators.
- * _`operand1`_ <br>
- The first operand of the operation.
- * _`operand2`_ _(Optional)_<br>
- The second operand of the operation.
- * _`operand3`_ _(Optional)_<br>
- The third operand of the operation.
+- _`operator`_ <br>
+ One of the unary, binary, or ternary operators.
+- _`operand1`_ <br>
+ The first operand of the operation.
+- _`operand2`_ _(Optional)_<br>
+ The second operand of the operation.
+- _`operand3`_ _(Optional)_<br>
+The third operand of the operation.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#if (op "===" value1 value2)}}Values are equal{{/if~}}<br>
{{~#op "-" value1}}{{/op~}}<br>
{{~op "?:" value1 "a" "b"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
Values are equal<br>-32<br>a
```
- Preview:
+Preview:
+
<pre>Values are equal<br>-32<br>a</pre>
</details>
-
### `get`
Gets a value from the custom state stack.
@@ -351,24 +383,27 @@ Gets a value from the custom state stack.
<details>
<summary>Syntax:</summary>
- <code>{{get <i>name</i>}}</code>
+<code>{{get <i>name</i>}}</code>
- * _`name`_ <br>
- The name of the variable to get.
+- _`name`_ <br>
+The name of the variable to get.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{get "some-text"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
This is the value of some-text!
```
-</details>
+</details>
### `set`
@@ -377,27 +412,30 @@ Assigns a value to the custom state stack.
<details>
<summary>Syntax:</summary>
- <code>{{#set <i>name</i>}}<i>value</i>{{/get}}</code><br>
- <code>{{set <i>name</i> <i>value</i>}}</code><br>
+<code>{{#set <i>name</i>}}<i>value</i>{{/get}}</code><br>
+<code>{{set <i>name</i> <i>value</i>}}</code><br>
- * _`name`_ <br>
- The name of the variable to assign.
- * _`value`_ <br>
- The value of the variable.
+- _`name`_ <br>
+ The name of the variable to assign.
+- _`value`_ <br>
+The value of the variable.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#set "some-text"}}This is the value of some-text!{{/set~}}
{{~set "some-number" 32}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
```
-</details>
+</details>
### `#scope`
@@ -408,16 +446,17 @@ and variable lookups will start from the most recent scope and work backwards un
<details>
<summary>Syntax:</summary>
- <code>{{#scope}}<i>content</i>{{/scope}}</code>
+<code>{{#scope}}<i>content</i>{{/scope}}</code>
- * _`name`_ <br>
- The name of the variable to assign.
- * _`value`_ <br>
- The value of the variable.
+- _`name`_ <br>
+ The name of the variable to assign.
+- _`value`_ <br>
+The value of the variable.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{~set "key" 32~}}
{{~get "key"~}},
@@ -429,12 +468,14 @@ and variable lookups will start from the most recent scope and work backwards un
{{~get "key"~}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
32,32,64,32
```
-</details>
+</details>
### `property`
@@ -443,26 +484,29 @@ Repeatedly gets a property of an object.
<details>
<summary>Syntax:</summary>
- <code>{{property <i>object</i> <i>property1</i> <i>property2</i> <i>...</i> <i>propertyN</i>}}</code>
+<code>{{property <i>object</i> <i>property1</i> <i>property2</i> <i>...</i> <i>propertyN</i>}}</code>
- * _`object`_ <br>
- The initial object to use.
- * _`propertyN`_ <br>
- A chain of property names to get on the object.
+- _`object`_ <br>
+ The initial object to use.
+- _`propertyN`_ <br>
+A chain of property names to get on the object.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{property someObject "field" 0 "toString"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
function toString() { [native code] }
```
-</details>
+</details>
### `noop`
@@ -471,21 +515,25 @@ No-op. Returns the inner contents of the template.
<details>
<summary>Syntax:</summary>
- <code>{{#noop}}<i>content</i>{{/noop}}</code>
+<code>{{#noop}}<i>content</i>{{/noop}}</code>
+
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{noop}}Unchanged content{{/noop}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
Unchanged content
```
-</details>
+</details>
### `isMoraPitchHigh`
@@ -494,21 +542,25 @@ Returns whether or not a mora will have a high pitch, given the index of the mor
<details>
<summary>Syntax:</summary>
- <code>{{isMoraPitchHigh <i>index</i> <i>position</i>}}</code>
+<code>{{isMoraPitchHigh <i>index</i> <i>position</i>}}</code>
+
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#if (isMoraPitchHigh 1 2)}}High pitch{{else}}Low pitch{{/if}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
High pitch
```
-</details>
+</details>
### `getKanaMorae`
@@ -517,25 +569,29 @@ Returns an array of the mora for a kana string.
<details>
<summary>Syntax:</summary>
- <code>{{getKanaMorae <i>kana-string</i>}}</code>
+<code>{{getKanaMorae <i>kana-string</i>}}</code>
+
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#each (getKanaMorae "よみたん")}}{{{.}}}<br>{{/each}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
よ<br>み<br>た<br>ん<br>
```
- Preview:
+Preview:
+
<pre>よ<br>み<br>た<br>ん<br></pre>
</details>
-
### `typeof`
Returns the type of a value. `#typeof` in the block form will always return `'string'`.
@@ -543,29 +599,32 @@ Returns the type of a value. `#typeof` in the block form will always return `'st
<details>
<summary>Syntax:</summary>
- <code>{{typeof <i>value</i>}}</code><br>
- <code>{{#typeof}}<i>value</i>{{/typeof}}</code><br>
+<code>{{typeof <i>value</i>}}</code><br>
+<code>{{#typeof}}<i>value</i>{{/typeof}}</code><br>
- * _`value`_ <br>
- The value to check.
+- _`value`_ <br>
+The value to check.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{typeof "よみたん"}}
{{typeof 1}}
{{#typeof}}よみたん{{/typeof}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
string
number
string
```
-</details>
+</details>
### `join`
@@ -574,27 +633,30 @@ Joins the arguments to a single string with a separator, flattening any argument
<details>
<summary>Syntax:</summary>
- <code>{{join <i>separator</i> <i>value1</i> <i>value2</i> <i>valueN</i>...}}</code><br>
+<code>{{join <i>separator</i> <i>value1</i> <i>value2</i> <i>valueN</i>...}}</code><br>
- * _`separator`_ <br>
- The separator string to use between values.
- * _`valueN`_ <br>
- An individual value to join into the resulting string
+- _`separator`_ <br>
+ The separator string to use between values.
+- _`valueN`_ <br>
+An individual value to join into the resulting string
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{set "index" 32~}}
{{~join "_" "yomitan" (get "index") "value"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
yomitan_32_value
```
-</details>
+</details>
### `concat`
@@ -603,25 +665,28 @@ Joins the arguments to a single string, without flattening arguments that are ar
<details>
<summary>Syntax:</summary>
- <code>{{concat <i>value1</i> <i>value1</i> <i>valueN</i>...}}</code><br>
+<code>{{concat <i>value1</i> <i>value1</i> <i>valueN</i>...}}</code><br>
- * _`valueN`_ <br>
- A value to join into the resulting string
+- _`valueN`_ <br>
+A value to join into the resulting string
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{set "index" 32~}}
{{~concat "yomitan_" (get "index") "_value"}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
yomitan_32_value
```
-</details>
+</details>
### `pitchCategories`
@@ -630,24 +695,27 @@ Returns an array representing the different pitch categories for a specific term
<details>
<summary>Syntax:</summary>
- <code>{{pitchCategories @root}}</code><br>
+<code>{{pitchCategories @root}}</code><br>
- * _`@root`_ <br>
- The argument passed should always be the root data object.
+- _`@root`_ <br>
+The argument passed should always be the root data object.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
[{{#each (pitchCategories @root)}}{{.}}{{#unless @last}}, {{/unless}}{{/each}}]
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
[heiban, kifuku]
```
-</details>
+</details>
### `formatGlossary`
@@ -657,26 +725,29 @@ structured-content generation.
<details>
<summary>Syntax:</summary>
- <code>{{formatGlossary <i>dictionary</i> <i>definitionEntry</i>}}</code><br>
+<code>{{formatGlossary <i>dictionary</i> <i>definitionEntry</i>}}</code><br>
- * _`dictionary`_ <br>
- The dictionary that the glossary entry belongs to.
- * _`definitionEntry`_ <br>
- The definition entry object in raw form.
+- _`dictionary`_ <br>
+ The dictionary that the glossary entry belongs to.
+- _`definitionEntry`_ <br>
+The definition entry object in raw form.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#each glossary}}{{formatGlossary ../dictionary .}}{{/each}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
Here is the content of a gloss, which may include formatted HTML.
```
-</details>
+</details>
### `hasMedia` & `getMedia`
@@ -686,29 +757,30 @@ These functions are used together in order to request media and other types of o
<details>
<summary>Syntax:</summary>
- <code>{{hasMedia <i>type</i> <i>args</i>...}}</code><br>
- <code>{{getMedia <i>type</i> <i>args</i>... <i>[escape=true|false]</i>}}</code><br>
+<code>{{hasMedia <i>type</i> <i>args</i>...}}</code><br>
+<code>{{getMedia <i>type</i> <i>args</i>... <i>[escape=true|false]</i>}}</code><br>
- * _`type`_ <br>
- The type of media to check for.
- * _`args`_ <br>
- Additional arguments for the media. The arguments depend on the media type.
- * _`escape`_ _(optional)_ <br>
- Whether or not the resulting text should be HTML-escaped. If omitted, defaults to `true`.
+- _`type`_ <br>
+ The type of media to check for.
+- _`args`_ <br>
+ Additional arguments for the media. The arguments depend on the media type.
+- _`escape`_ _(optional)_ <br>
+ Whether or not the resulting text should be HTML-escaped. If omitted, defaults to `true`.
- **Available media types and arguments**
+**Available media types and arguments**
- * <code>"audio"</code>
- * <code>"screenshot"</code>
- * <code>"clipboardImage"</code>
- * <code>"clipboardText"</code>
- * <code>"selectionText"</code>
- * <code>"textFurigana" <i>japaneseText</i> <i>readingMode="default|hiragana|katakana"</i></code>
- * <code>"dictionaryMedia" <i>fileName</i> <i>dictionary="Dictionary Name"</i></code>
+- <code>"audio"</code>
+- <code>"screenshot"</code>
+- <code>"clipboardImage"</code>
+- <code>"clipboardText"</code>
+- <code>"selectionText"</code>
+- <code>"textFurigana" <i>japaneseText</i> <i>readingMode="default|hiragana|katakana"</i></code>
+- <code>"dictionaryMedia" <i>fileName</i> <i>dictionary="Dictionary Name"</i></code>
</details>
<details>
<summary>Examples:</summary>
+<!-- prettier-ignore -->
```handlebars
{{#if (hasMedia "audio")}}The audio file name is: {{getMedia "audio"}}{{/if}}
@@ -725,7 +797,9 @@ These functions are used together in order to request media and other types of o
{{#if (hasMedia "dictionaryMedia" "image.png" dictionary="Example Dictionary")}}The remapped file name for image.png is: {{getMedia "dictionaryMedia" "image.png" dictionary="Example Dictionary"}}{{/if}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
The audio file name is: yomitan_audio_にほんご_日本語.mp3
@@ -743,8 +817,8 @@ These functions are used together in order to request media and other types of o
The remapped file name for image.png is: yomitan_dictionary_media_1_にほんご_日本語.png
```
-</details>
+</details>
### `pronunciation`
@@ -754,30 +828,31 @@ same as the system used for generating popup and search page dictionary entries.
<details>
<summary>Syntax:</summary>
- <code>{{pronunciation <i>format=string</i> <i>reading=string</i> <i>downstepPosition=integer</i> <i>[nasalPositions=array]</i> <i>[devoicePositions=array]</i>}}</code><br>
+<code>{{pronunciation <i>format=string</i> <i>reading=string</i> <i>downstepPosition=integer</i> <i>[nasalPositions=array]</i> <i>[devoicePositions=array]</i>}}</code><br>
- * _`format`_ <br>
- The format of the HTML to generate. This can be any of the following values:
- * `'text'`
- * `'graph'`
- * `'position'`
- * _`reading`_ <br>
- The kana reading of the term.
- * _`downstepPosition`_ <br>
- The mora position of the downstep in the reading.
- * _`nasalPositions`_ _(optional)_ <br>
- An array of indices of mora that have a nasal pronunciation.
- * _`devoicePositions`_ _(optional)_ <br>
- An array of indices of mora that are devoiced.
+- _`format`_ <br>
+ The format of the HTML to generate. This can be any of the following values:
+ - `'text'`
+ - `'graph'`
+ - `'position'`
+- _`reading`_ <br>
+ The kana reading of the term.
+- _`downstepPosition`_ <br>
+ The mora position of the downstep in the reading.
+- _`nasalPositions`_ _(optional)_ <br>
+ An array of indices of mora that have a nasal pronunciation.
+- _`devoicePositions`_ _(optional)_ <br>
+An array of indices of mora that are devoiced.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{~pronunciation format='text' reading='よむ' downstepPosition=1~}}
```
-</details>
+</details>
### `hiragana`
@@ -786,18 +861,19 @@ Converts katakana text to hiragana.
<details>
<summary>Syntax:</summary>
- <code>{{hiragana <i>value</i> <i>[keepProlongedSoundMarks=true|false]</i>}}</code><br>
- <code>{{#hiragana <i>[keepProlongedSoundMarks=true|false]</i>}}<i>value</i>{{/hiragana}}</code><br>
+<code>{{hiragana <i>value</i> <i>[keepProlongedSoundMarks=true|false]</i>}}</code><br>
+<code>{{#hiragana <i>[keepProlongedSoundMarks=true|false]</i>}}<i>value</i>{{/hiragana}}</code><br>
- * _`value`_ <br>
- The text to convert.
- * _`keepProlongedSoundMarks`_ _(optional)_ <br>
- Whether or not the `ー` character should be kept or converted to a vowel character.
- Defaults to `false` if not specified.
+- _`value`_ <br>
+ The text to convert.
+- _`keepProlongedSoundMarks`_ _(optional)_ <br>
+Whether or not the `ー` character should be kept or converted to a vowel character.
+Defaults to `false` if not specified.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{hiragana "よみたん ヨミたん ヨミタン"}}
{{#hiragana}}よみたん ヨミたん ヨミタン{{/hiragana}}
@@ -805,15 +881,17 @@ Converts katakana text to hiragana.
{{#hiragana keepProlongedSoundMarks=true}}ローマ字{{/hiragana}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
よみたん よみたん よみたん
よみたん よみたん よみたん
ろうま字
ろーま字
```
-</details>
+</details>
### `katakana`
@@ -822,23 +900,27 @@ Converts hiragana text to katakana.
<details>
<summary>Syntax:</summary>
- <code>{{katakana <i>text</i>}}</code><br>
- <code>{{#katakana}}<i>text</i>{{/katakana}}</code><br>
+<code>{{katakana <i>text</i>}}</code><br>
+<code>{{#katakana}}<i>text</i>{{/katakana}}</code><br>
- * _`text`_ <br>
- The text to convert.
+- _`text`_ <br>
+The text to convert.
</details>
<details>
<summary>Example:</summary>
+<!-- prettier-ignore -->
```handlebars
{{katakana "よみたん ヨミたん ヨミタン"}}
{{#katakana}}よみたん ヨミたん ヨミタン{{/katakana}}
```
- Output:
+Output:
+
+<!-- prettier-ignore -->
```html
ヨミタン ヨミタン ヨミタン
ヨミタン ヨミタン ヨミタン
```
+
</details>