aboutsummaryrefslogtreecommitdiff
path: root/docs/templates.md
blob: 3ae8c58e48ef2c87fb84cfddae61a8d87308636f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
# Templates

## Helpers

Yomichan 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.
This function can be helpful for debugging values when creating templates.

<details>
  <summary>Syntax:</summary>

  <code>{{dumpObject <i>object</i>}}</code>

  * _`object`_ <br>
    The object to convert.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  <pre>{{dumpObject .}}</pre>
  ```

  Output:
  ```html
  <pre>{
      "key": "value"
  }</pre>
  ```

  Preview:
  ```html
  {
      "key": "value"
  }
  ```
</details>


### `furigana`

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>

  * _`definition`_ <br>
    The definition to convert.
  * _`expression`_ <br>
    The expression to convert.
  * _`reading`_ <br>
    The reading to convert.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{furigana .}}
  {{furigana "読む" "よむ"}}
  ```

  Output:
  ```html
  <ruby><rt></rt></ruby>  ```

  Preview
  <pre><ruby>読<rt>よ</rt></ruby>む</pre>
</details>


### `furiganaPlain`

Converts a definition or expression/reading pair to its simplified furigana representation.

<details>
  <summary>Syntax:</summary>

  <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.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{~furiganaPlain .~}}
  {{furiganaPlain "読む" "よむ"}}
  ```

  Output:
  ```html
  読[よ]む
  ```
</details>


### `multiLine`

Replaces newline characters with a forced HTML line break `<br>`.

<details>
  <summary>Syntax:</summary>

  <code>{{#multiLine}}<i>text with multiple lines</i>{{/multiLine}}</code>
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#multiLine~}}
  some
  multiline
  text
  {{~/multiLine}}
  ```

  Output:
  ```html
  some<br>multiline<br>text
  ```

  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.

<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>

  * _`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>

  ```handlebars
  {{#regexReplace "\(([^)]*)\)" "$1" "g"~}}Here is (some) (text) (in) (parentheses){{~/regexReplace}}
  ```

  Output:
  ```html
  Here is some text in parentheses
  ```
</details>


### `regexMatch`

Uses a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to return only the content that matches the pattern.

<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>

  * _`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>

  ```handlebars
  {{#regexMatch "\(([^)]*)\)" "g"~}}Here is (some) (text) (in) (parentheses){{~/regexMatch}}
  ```

  Output:
  ```html
  (some)(text)(in)(parentheses)
  ```
</details>


### `mergeTags`

Creates a set of all unique tags for the definition and returns a text representation of the tags separated by commas.

<details>
  <summary>Syntax:</summary>

  <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.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{~mergeTags definition group merge~}}
  ```

  Output:
  ```html
  v5m, vt, JMdict (English)
  ```
</details>


### `eachUpTo`

Similar to the built-in `each` function, but iterates up to a maximum count.
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>

  * _`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>

  ```handlebars
  {{~#eachUpTo someArray 5}}{{{.}}}<br>{{else}}Empty{{/mergeTags~}}
  ```

  Output:
  ```html
  someArray[0]<br>someArray[1]<br>someArray[2]<br>someArray[3]<br>someArray[4]<br>
  ```

  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.
This allows it to be used similar to an [`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) operation.

<details>
  <summary>Syntax:</summary>

  <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.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#each (spread array1 array2)}}{{{.}}}<br>{{/each}}
  ```

  Output:
  ```html
  array1[0]<br>array1[1]<br>array2[0]<br>array2[1]<br>
  ```

  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: `?:`

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>}}{{/op}}</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.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#if (op "===" value1 value2)}}Values are equal{{/op~}}<br>
  {{~#op "-" value1}}{{/op~}}<br>
  {{~op "?:" value1 "a" "b"}}
  ```

  Output:
  ```html
  Values are equal<br>-32<br>a
  ```

  Preview:
  <pre>Values are equal<br>-32<br>a</pre>
</details>


### `get`

Gets a value from the custom state stack.

<details>
  <summary>Syntax:</summary>

  <code>{{get <i>name</i>}}</code>

  * _`name`_ <br>
    The name of the variable to get.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{get "some-text"}}
  ```

  Output:
  ```html
  This is the value of some-text!
  ```
</details>


### `set`

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>

  * _`name`_ <br>
    The name of the variable to assign.
  * _`value`_ <br>
    The value of the variable.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#set "some-text"}}This is the value of some-text!{{/set~}}
  {{~set "some-number" 32}}
  ```

  Output:
  ```html
  ```
</details>


### `scope`

Pushes a new variable scope to the custom state stack.
Variable assignments are applied to the most recent scope,
and variable lookups will start from the most recent scope and work backwards until a value is found.

<details>
  <summary>Syntax:</summary>

  <code>{{#scope}}<i>content</i>{{/scope}}</code>

  * _`name`_ <br>
    The name of the variable to assign.
  * _`value`_ <br>
    The value of the variable.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{~set "key" 32~}}
  {{~get "key"~}},
  {{~#scope~}}
    {{~#get "key"~}},
    {{~#set "key" 64~}}
    {{~#get "key"~}},
  {{~/scope~}}
  {{~get "key"~}}
  ```

  Output:
  ```html
  32,32,64,32
  ```
</details>


### `property`

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>

  * _`object`_ <br>
    The initial object to use.
  * _`propertyN`_ <br>
    A chain of property names to get on the object.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{property someObject "field" 0 "toString"}}
  ```

  Output:
  ```html
  function toString() { [native code] }
  ```
</details>


### `noop`

No-op. Returns the inner contents of the template.

<details>
  <summary>Syntax:</summary>

  <code>{{#noop}}<i>content</i>{{/noop}}</code>
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{noop}}Unchanged content{{/noop}}
  ```

  Output:
  ```html
  Unchanged content
  ```
</details>


### `isMoraPitchHigh`

Returns whether or not a mora will have a high pitch, given the index of the mora and the position of the downstep.

<details>
  <summary>Syntax:</summary>

  <code>{{isMoraPitchHigh <i>index</i> <i>position</i>}}</code>
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#if (isMoraPitchHigh 1 2)}}High pitch{{else}}Low pitch{{/if}}
  ```

  Output:
  ```html
  High pitch
  ```
</details>


### `getKanaMorae`

Returns an array of the mora for a kana string.

<details>
  <summary>Syntax:</summary>

  <code>{{getKanaMorae <i>kana-string</i>}}</code>
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#each (getKanaMorae "よみちゃん")}}{{{.}}}<br>{{/each}}
  ```

  Output:
  ```html<br><br>ちゃ<br><br>
  ```

  Preview:
  <pre>よ<br>み<br>ちゃ<br>ん<br></pre>
</details>


### `typeof`

Returns the type of a value.

<details>
  <summary>Syntax:</summary>

  <code>{{typeof <i>value</i>}}</code><br>
  <code>{{#typeof}}<i>value</i>{{/typeof}}</code><br>

  * _`value`_ <br>
    The value to check.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{typeof "よみちゃん"}}
  {{typeof 1}}
  {{#typeof}}よみちゃん{{/typeof}}
  ```

  Output:
  ```html
  string
  number
  string
  ```
</details>


### `join`

Joins the arguments to a single string with a separator, flattening any arguments that are arrays.

<details>
  <summary>Syntax:</summary>

  <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
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{set "index" 32~}}
  {{~join "_" "yomichan" (get "index") "value"}}
  ```

  Output:
  ```html
  yomichan_32_value
  ```
</details>


### `concat`

Joins the arguments to a single string, without flattening arguments that are arrays.

<details>
  <summary>Syntax:</summary>

  <code>{{concat <i>value1</i> <i>value1</i> <i>valueN</i>...}}</code><br>

  * _`valueN`_ <br>
    A value to join into the resulting string
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{set "index" 32~}}
  {{~concat "yomichan_" (get "index") "_value"}}
  ```

  Output:
  ```html
  yomichan_32_value
  ```
</details>


### `pitchCategories`

Returns an array representing the different pitch categories for a specific term.

<details>
  <summary>Syntax:</summary>

  <code>{{#pitchCategories @root}}{{/pitchCategories}}</code><br>

  * _`@root`_ <br>
    The argument passed should always be the root data object.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  [{{#each (pitchCategories @root)}}{{.}}{{#unless @last}}, {{/unless}}{{/each}}]
  ```

  Output:
  ```html
  [heiban, kifuku]
  ```
</details>


### `formatGlossary`

Formats a glossary entry to a HTML content string. This helper handles image and
structured-content generation.

<details>
  <summary>Syntax:</summary>

  <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.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#each glossary}}{{formatGlossary ../dictionary .}}{{/each}}
  ```

  Output:
  ```html
  Here is the content of a gloss, which may include formatted HTML.
  ```
</details>


### `hasMedia` & `getMedia`

Checks to see if a certain type of media is available for a card and injects the relevant content.
These functions are used together in order to request media and other types of optional asynchronous content.

<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>

  * _`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**

  * <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>

  ```handlebars
  {{#if (hasMedia "audio")}}The audio file name is: {{getMedia "audio"}}{{/if}}

  {{#if (hasMedia "screenshot")}}The screenshot file name is: {{getMedia "screenshot"}}{{/if}}

  {{#if (hasMedia "clipboardImage")}}The clipboard image file name is: {{getMedia "clipboardImage"}}{{/if}}

  {{#if (hasMedia "clipboardText")}}The clipboard text is: {{getMedia "clipboardText"}}{{/if}}

  {{#if (hasMedia "selectionText")}}The selection text is: {{getMedia "selectionText"}}{{/if}}

  {{#if (hasMedia "textFurigana" "日本語")}}This is an example of text with generated furigana: {{getMedia "textFurigana" "日本語" escape=false}}{{/if}}

  {{#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:
  ```html
  The audio file name is: yomichan_audio_にほんご_日本語.mp3

  The screenshot file name is: yomichan_browser_screenshot_にほんご_日本語.png

  The clipboard image file name is: yomichan_clipboard_image_にほんご_日本語.png

  The clipboard text is: This is the clipboard text

  The selection text is: This is the selection text

  The selection text is: This is the selection text

  This is an example of text with generated furigana: <ruby>日本語<rt>にほんご</rt></ruby>

  The remapped file name for image.png is: yomichan_dictionary_media_1_にほんご_日本語.png
  ```
</details>


### `pronunciation`

Converts pronunciation information into a formatted HTML content string. The display layout is the
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>

  * _`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>

  ```handlebars
  {{~pronunciation format='text' reading='よむ' downstepPosition=1~}}
  ```
</details>


### `hiragana`

Converts katakana text to hiragana.

<details>
  <summary>Syntax:</summary>

  <code>{{#hiragana <i>value</i> <i>[keepProlongedSoundMarks=true|false]</i>}}{{/hiragana}}</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.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#hiragana "よみちゃん ヨミちゃん ヨミチャン"}}{{/hiragana}}
  {{#hiragana}}よみちゃん ヨミちゃん ヨミチャン{{/hiragana}}
  {{#hiragana}}ローマ字{{/hiragana}}
  {{#hiragana keepProlongedSoundMarks=true}}ローマ字{{/hiragana}}
  ```

  Output:
  ```html
  よみちゃん よみちゃん よみちゃん
  よみちゃん よみちゃん よみちゃん
  ろうま字
  ろーま字
  ```
</details>


### `katakana`

Converts hiragana text to katakana.

<details>
  <summary>Syntax:</summary>

  <code>{{#katakana <i>text</i>}}{{/katakana}}</code><br>
  <code>{{#katakana}}<i>text</i>{{/katakana}}</code><br>

  * _`text`_ <br>
    The text to convert.
</details>
<details>
  <summary>Example:</summary>

  ```handlebars
  {{#katakana "よみちゃん ヨミちゃん ヨミチャン"}}{{/katakana}}
  {{#katakana}}よみちゃん ヨミちゃん ヨミチャン{{/katakana}}
  ```

  Output:
  ```html
  ヨミチャン ヨミチャン ヨミチャン
  ヨミチャン ヨミチャン ヨミチャン
  ```
</details>