diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/browser-bugs.md | 154 | ||||
-rw-r--r-- | docs/permissions.md | 16 | ||||
-rw-r--r-- | docs/templates.md | 506 |
3 files changed, 390 insertions, 286 deletions
diff --git a/docs/browser-bugs.md b/docs/browser-bugs.md index 2b7b3bad..6e4912b5 100644 --- a/docs/browser-bugs.md +++ b/docs/browser-bugs.md @@ -3,111 +3,133 @@ This page lists several of the browser bugs that have affected Yomichan over the years. ## Audio doesn't work when autoplay=false -* **Browser**: Firefox -* **Date**: 2018-06-17 -* **Issue**: [#129](https://github.com/FooSoft/yomichan/issues/129), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1466926) + +- **Browser**: Firefox +- **Date**: 2018-06-17 +- **Issue**: [#129](https://github.com/FooSoft/yomichan/issues/129), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1466926) ## Ruby text layouts don't always work correctly for certain fonts -* **Browser**: Chrome -* **Date**: 2019-08-11 -* **Links**: [#178](https://github.com/FooSoft/yomichan/issues/178), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1045755), [Demo](https://github.com/toasted-nutbread/chrome-layout-bug) + +- **Browser**: Chrome +- **Date**: 2019-08-11 +- **Links**: [#178](https://github.com/FooSoft/yomichan/issues/178), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1045755), [Demo](https://github.com/toasted-nutbread/chrome-layout-bug) ## document.execCommand('paste') doesn't work correctly on web extension background page -* **Browser**: Firefox -* **Date**: 2019-12-14 -* **Links**: [#307](https://github.com/FooSoft/yomichan/pull/307), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1603985), [Demo](https://github.com/toasted-nutbread/firefox-clipboard-paste-bug) + +- **Browser**: Firefox +- **Date**: 2019-12-14 +- **Links**: [#307](https://github.com/FooSoft/yomichan/pull/307), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1603985), [Demo](https://github.com/toasted-nutbread/firefox-clipboard-paste-bug) ## Touch events can have incorrect position -* **Browser**: Firefox -* **Date**: 2020-01-18 -* **Links**: [#316](https://github.com/FooSoft/yomichan/pull/316), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1610145), [Demo](https://github.com/toasted-nutbread/firefox-touch-position-bug) + +- **Browser**: Firefox +- **Date**: 2020-01-18 +- **Links**: [#316](https://github.com/FooSoft/yomichan/pull/316), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1610145), [Demo](https://github.com/toasted-nutbread/firefox-touch-position-bug) ## Triple click doesn't select text properly -* **Browser**: Firefox -* **Date**: 2020-01-30 -* **Issue**: [#340](https://github.com/FooSoft/yomichan/pull/340), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1612236), [Demo](https://github.com/toasted-nutbread/firefox-text-selection-bug) + +- **Browser**: Firefox +- **Date**: 2020-01-30 +- **Issue**: [#340](https://github.com/FooSoft/yomichan/pull/340), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1612236), [Demo](https://github.com/toasted-nutbread/firefox-text-selection-bug) ## unhandledrejection event doesn't work correctly in content scripts -* **Browser**: Firefox -* **Date**: 2020-04-12 -* **Issue**: [#454](https://github.com/FooSoft/yomichan/pull/454), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1632270) + +- **Browser**: Firefox +- **Date**: 2020-04-12 +- **Issue**: [#454](https://github.com/FooSoft/yomichan/pull/454), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1632270) ## chrome.tabs.sendMessage doesn't work correctly -* **Browser**: Firefox (Nightly) -* **Date**: 2020-06-04 -* **Links**: [#588](https://github.com/FooSoft/yomichan/issues/588), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1643649), [Demo](https://github.com/toasted-nutbread/firefox-web-extension-send-message-bug) + +- **Browser**: Firefox (Nightly) +- **Date**: 2020-06-04 +- **Links**: [#588](https://github.com/FooSoft/yomichan/issues/588), [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1643649), [Demo](https://github.com/toasted-nutbread/firefox-web-extension-send-message-bug) ## CSS animations don't work correctly when using an attribute on the root -* **Browser**: Chrome -* **Date**: 2020-06-05 -* **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1087188), [Demo](https://github.com/toasted-nutbread/chrome-animated-text-color-bug) + +- **Browser**: Chrome +- **Date**: 2020-06-05 +- **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1087188), [Demo](https://github.com/toasted-nutbread/chrome-animated-text-color-bug) ## Pen pointer events have various issues -* **Browser**: Firefox -* **Date**: 2020-09-12 -* **Links**: [#819](https://github.com/FooSoft/yomichan/pull/819), [#820](https://github.com/FooSoft/yomichan/pull/820), [#821](https://github.com/FooSoft/yomichan/pull/821), [#824](https://github.com/FooSoft/yomichan/pull/824), [Report 1](https://bugzilla.mozilla.org/show_bug.cgi?id=1449660), [Report 2](https://bugzilla.mozilla.org/show_bug.cgi?id=1487509), [Report 3](https://bugzilla.mozilla.org/show_bug.cgi?id=1583480), [Report 4](https://bugzilla.mozilla.org/show_bug.cgi?id=1583519), [Report 5](https://bugzilla.mozilla.org/show_bug.cgi?id=1631377) + +- **Browser**: Firefox +- **Date**: 2020-09-12 +- **Links**: [#819](https://github.com/FooSoft/yomichan/pull/819), [#820](https://github.com/FooSoft/yomichan/pull/820), [#821](https://github.com/FooSoft/yomichan/pull/821), [#824](https://github.com/FooSoft/yomichan/pull/824), [Report 1](https://bugzilla.mozilla.org/show_bug.cgi?id=1449660), [Report 2](https://bugzilla.mozilla.org/show_bug.cgi?id=1487509), [Report 3](https://bugzilla.mozilla.org/show_bug.cgi?id=1583480), [Report 4](https://bugzilla.mozilla.org/show_bug.cgi?id=1583519), [Report 5](https://bugzilla.mozilla.org/show_bug.cgi?id=1631377) ## Cannot read clipboard from service worker in a MV3 chrome extension -* **Browser**: Chrome -* **Date**: 2020-12-18 -* **Links**: [#455](https://github.com/FooSoft/yomichan/issues/455), [#1247](https://github.com/FooSoft/yomichan/issues/1247), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1160302) + +- **Browser**: Chrome +- **Date**: 2020-12-18 +- **Links**: [#455](https://github.com/FooSoft/yomichan/issues/455), [#1247](https://github.com/FooSoft/yomichan/issues/1247), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1160302) ## Textareas display incorrectly when they have an animated CSS transform -* **Browser**: Chrome -* **Date**: 2021-01-30 -* **Links**: [Demo](https://toasted-nutbread.github.io/chrome-textarea-transform-bug/), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1172666) + +- **Browser**: Chrome +- **Date**: 2021-01-30 +- **Links**: [Demo](https://toasted-nutbread.github.io/chrome-textarea-transform-bug/), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1172666) ## Chrome extensions using port connections can crash the browser using manifest version 3 -* **Browser**: Chrome -* **Date**: 2021-02-13 -* **Links**: [Demo](https://github.com/toasted-nutbread/chrome-extension-port-connect-crash), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1178179) + +- **Browser**: Chrome +- **Date**: 2021-02-13 +- **Links**: [Demo](https://github.com/toasted-nutbread/chrome-extension-port-connect-crash), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1178179) ## Chrome extension Port.onDisconnect event does not always fire in content scripts -* **Browser**: Chrome -* **Date**: 2021-02-13 -* **Links**: [Demo](https://github.com/toasted-nutbread/chrome-extension-port-disconnect-bug), [Report 1](https://bugs.chromium.org/p/chromium/issues/detail?id=1178188) (MV2), [Report 2](https://bugs.chromium.org/p/chromium/issues/detail?id=1178189) (MV3) + +- **Browser**: Chrome +- **Date**: 2021-02-13 +- **Links**: [Demo](https://github.com/toasted-nutbread/chrome-extension-port-disconnect-bug), [Report 1](https://bugs.chromium.org/p/chromium/issues/detail?id=1178188) (MV2), [Report 2](https://bugs.chromium.org/p/chromium/issues/detail?id=1178189) (MV3) ## Ruby elements with padding have incorrect layout -* **Browser**: Firefox -* **Date**: 2021-03-05 -* **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1696721) + +- **Browser**: Firefox +- **Date**: 2021-03-05 +- **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1696721) ## Focus changes don't preserve caret position for caret browsing -* **Browser**: Chrome -* **Date**: 2021-05-19 -* **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1211175) + +- **Browser**: Chrome +- **Date**: 2021-05-19 +- **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1211175) ## CSS :active state on <label> element doesn't match state on inner element -* **Browser**: Chrome -* **Date**: 2021-05-19 -* **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1211182) + +- **Browser**: Chrome +- **Date**: 2021-05-19 +- **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1211182) ## Caret browsing doesn't work properly for certain display:none elements -* **Browser**: Firefox -* **Date**: 2021-06-06 -* **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1714883) + +- **Browser**: Firefox +- **Date**: 2021-06-06 +- **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1714883) ## IndexedDB writes from a Worker thread do not persist if worker is terminated -* **Browser**: ~~Chrome~~, Firefox _(warning only)_ -* **Date**: 2021-08-07 -* **Links**: ~~[Chrome Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1237686)~~, [Firefox Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1724602) + +- **Browser**: ~~Chrome~~, Firefox _(warning only)_ +- **Date**: 2021-08-07 +- **Links**: ~~[Chrome Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1237686)~~, [Firefox Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1724602) ## Web extension content scripts don't run on certain about:blank popups -* **Browser**: Firefox -* **Date**: 2021-08-16 -* **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1726068) + +- **Browser**: Firefox +- **Date**: 2021-08-16 +- **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1726068) ## Touch events report incorrect clientX on wide pages with writing-mode:vertical-rl -* **Browser**: Chrome -* **Date**: 2022-01-31 -* **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1292815) + +- **Browser**: Chrome +- **Date**: 2022-01-31 +- **Links**: [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1292815) ## Chrome extensions can't auto-play media from an embedded extension frame -* **Browser**: Chrome -* **Date**: 2022-04-03 -* **Links**: [Demo](https://github.com/toasted-nutbread/chrome-extension-audio-autoplay-bug), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1312816) + +- **Browser**: Chrome +- **Date**: 2022-04-03 +- **Links**: [Demo](https://github.com/toasted-nutbread/chrome-extension-audio-autoplay-bug), [Report](https://bugs.chromium.org/p/chromium/issues/detail?id=1312816) ## DOMException.data sometimes throws error on assignment -* **Browser**: Firefox -* **Date**: 2022-06-25 -* **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1776555) + +- **Browser**: Firefox +- **Date**: 2022-06-25 +- **Links**: [Report](https://bugzilla.mozilla.org/show_bug.cgi?id=1776555) diff --git a/docs/permissions.md b/docs/permissions.md index 92d5e06f..d20d25f9 100644 --- a/docs/permissions.md +++ b/docs/permissions.md @@ -1,39 +1,39 @@ # Yomitan Permissions -* `<all_urls>` <br> +- `<all_urls>` <br> Yomitan requires access to all URLs in order to run scripts to scan text and show the definitions popup, request audio for playback and download, and connect with Anki. -* `storage` and `unlimitedStorage` <br> +- `storage` and `unlimitedStorage` <br> Yomitan uses storage permissions in order to save extension settings and dictionary data. `unlimitedStorage` is used to help prevent web browsers from unexpectedly deleting dictionary data. -* `declarativeNetRequest` <br> +- `declarativeNetRequest` <br> Yomitan uses this permission to ensure certain requests have valid and secure headers. This sometimes involves removing or changing the `Origin` request header, as this can be used to fingerprint browser configuration. -* `scripting` <br> +- `scripting` <br> Yomitan needs to inject content scripts and stylesheets into webpages in order to properly display the search popup. -* `offscreen` _(Chrome only)_ <br> +- `offscreen` _(Chrome only)_ <br> Yomitan uses this permission to create a secondary backend document that has DOM access, given that Manifest v3 service workers do not. Service workers can then reach out to out to this document in order to complete actions that require access to DOM APIs, such as any that require clipboard access. -* `clipboardWrite` <br> +- `clipboardWrite` <br> Yomitan supports simulating the `Ctrl+C` (copy to clipboard) keyboard shortcut when a definitions popup is open and focused. -* `clipboardRead` _(optional)_ <br> +- `clipboardRead` _(optional)_ <br> Yomitan supports automatically opening a search window when Japanese text is copied to the clipboard while the browser is running, depending on how certain settings are configured. This allows Yomitan to support scanning text from external applications, provided there is a way to copy text from those applications to the clipboard. -* `nativeMessaging` _(optional, unavailable on Firefox for Android)_ <br> +- `nativeMessaging` _(optional, unavailable on Firefox for Android)_ <br> Yomitan has the ability to communicate with an optional native messaging component in order to support parsing large blocks of Japanese text using [MeCab](https://en.wikipedia.org/wiki/MeCab). 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> |