-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support to table expression translation
- Loading branch information
1 parent
86d1bd4
commit 559c5ee
Showing
11 changed files
with
339 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createTranslationFunction } from "../lib/internal"; | ||
|
||
export const TABLE_TRANSLATION_STYLES = [ | ||
"unicode", | ||
"unicode bold", | ||
"unicode rounded", | ||
"unicode double", | ||
"unicode with bold header", | ||
"unicode with double header", | ||
"unicode cells", | ||
"unicode cells 2", | ||
"ascii", | ||
"ascii rounded", | ||
"ascii with header 1", | ||
"ascii with header 2", | ||
"ascii light header", | ||
"ascii light header/separator", | ||
"ascii light header/separator/border", | ||
"ascii light separator/border", | ||
"ascii light border", | ||
"conceptual", | ||
] as const; | ||
|
||
/** | ||
* Represents the style of a table expression translation. | ||
*/ | ||
export type TableTranslationStyle = (typeof TABLE_TRANSLATION_STYLES)[number]; | ||
|
||
/** | ||
* Options for table expression translation. | ||
*/ | ||
export type TableTranslationOptions = { | ||
style?: TableTranslationStyle; | ||
}; | ||
|
||
export const table = | ||
createTranslationFunction<TableTranslationOptions>("Table"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Table expression translation > With options {"style":"ascii light border"} > should translate a simple table 1`] = ` | ||
"+----------------------------+ | ||
|Column 1 Column 2 Column 3| | ||
|C++ Web Assembly| | ||
|Javascript CSS HTML | | ||
+----------------------------+ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii light header"} > should translate a simple table 1`] = ` | ||
"Column 1 Column 2 Column 3 | ||
---------- -------- -------- | ||
C++ Web Assembly | ||
Javascript CSS HTML | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii light header/separator"} > should translate a simple table 1`] = ` | ||
"Column 1 |Column 2|Column 3 | ||
----------|--------|-------- | ||
C++ |Web |Assembly | ||
Javascript|CSS |HTML | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii light header/separator/border"} > should translate a simple table 1`] = ` | ||
"+----------+--------+--------+ | ||
|Column 1 |Column 2|Column 3| | ||
+----------+--------+--------| | ||
|C++ |Web |Assembly| | ||
|Javascript|CSS |HTML | | ||
+----------+--------+--------+ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii light separator/border"} > should translate a simple table 1`] = ` | ||
"+----------+--------+--------+ | ||
|Column 1 |Column 2|Column 3| | ||
|C++ |Web |Assembly| | ||
|Javascript|CSS |HTML | | ||
+----------+--------+--------+ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii rounded"} > should translate a simple table 1`] = ` | ||
".----------+--------+--------. | ||
|Column 1 |Column 2|Column 3| | ||
|----------+--------+--------| | ||
|C++ |Web |Assembly| | ||
|----------+--------+--------| | ||
|Javascript|CSS |HTML | | ||
'----------+--------+--------' | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii with header 1"} > should translate a simple table 1`] = ` | ||
"|==============================| | ||
| Column 1 |Column 2|Column 3 | | ||
|==============================| | ||
|C++ |Web |Assembly| | ||
+----------+--------+--------+ | ||
|Javascript|CSS |HTML | | ||
+----------+--------+--------+ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii with header 2"} > should translate a simple table 1`] = ` | ||
"============================== | ||
|Column 1 |Column 2|Column 3| | ||
============================== | ||
|C++ |Web |Assembly| | ||
+----------+--------+--------+ | ||
|Javascript|CSS |HTML | | ||
+----------+--------+--------+ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"ascii"} > should translate a simple table 1`] = ` | ||
"+----------+--------+--------+ | ||
|Column 1 |Column 2|Column 3| | ||
+----------+--------+--------+ | ||
|C++ |Web |Assembly| | ||
+----------+--------+--------+ | ||
|Javascript|CSS |HTML | | ||
+----------+--------+--------+ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"conceptual"} > should translate a simple table 1`] = ` | ||
" __________ ________ ________ | ||
/Column 1 \\/Column 2\\/Column 3\\ | ||
\\__________/\\________/\\________/ | ||
/C++ \\/Web \\/Assembly\\ | ||
\\__________/\\________/\\________/ | ||
/Javascript\\/CSS \\/HTML \\ | ||
\\__________/\\________/\\________/ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode bold"} > should translate a simple table 1`] = ` | ||
"┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┓ | ||
┃Column 1 ┃Column 2┃Column 3┃ | ||
┣━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━┫ | ||
┃C++ ┃Web ┃Assembly┃ | ||
┣━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━┫ | ||
┃Javascript┃CSS ┃HTML ┃ | ||
┗━━━━━━━━━━┻━━━━━━━━┻━━━━━━━━┛ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode cells 2"} > should translate a simple table 1`] = ` | ||
"╭────────────────────────────────╮ | ||
│╭──────────╮╭────────╮╭────────╮│ | ||
││Column 1 ││Column 2││Column 3││ | ||
│╰──────────╯╰────────╯╰────────╯│ | ||
│╭──────────╮╭────────╮╭────────╮│ | ||
││C++ ││Web ││Assembly││ | ||
│╰──────────╯╰────────╯╰────────╯│ | ||
│╭──────────╮╭────────╮╭────────╮│ | ||
││Javascript││CSS ││HTML ││ | ||
│╰──────────╯╰────────╯╰────────╯│ | ||
╰────────────────────────────────╯ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode cells"} > should translate a simple table 1`] = ` | ||
"╭──────────╮╭────────╮╭────────╮ | ||
│Column 1 ││Column 2││Column 3│ | ||
╰──────────╯╰────────╯╰────────╯ | ||
╭──────────╮╭────────╮╭────────╮ | ||
│C++ ││Web ││Assembly│ | ||
╰──────────╯╰────────╯╰────────╯ | ||
╭──────────╮╭────────╮╭────────╮ | ||
│Javascript││CSS ││HTML │ | ||
╰──────────╯╰────────╯╰────────╯ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode double"} > should translate a simple table 1`] = ` | ||
"╔══════════╦════════╦════════╗ | ||
║Column 1 ║Column 2║Column 3║ | ||
╠══════════╬════════╬════════╣ | ||
║C++ ║Web ║Assembly║ | ||
╠══════════╬════════╬════════╣ | ||
║Javascript║CSS ║HTML ║ | ||
╚══════════╩════════╩════════╝ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode rounded"} > should translate a simple table 1`] = ` | ||
"╭──────────┬────────┬────────╮ | ||
│Column 1 │Column 2│Column 3│ | ||
├──────────┼────────┼────────┤ | ||
│C++ │Web │Assembly│ | ||
├──────────┼────────┼────────┤ | ||
│Javascript│CSS │HTML │ | ||
╰──────────┴────────┴────────╯ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode with bold header"} > should translate a simple table 1`] = ` | ||
"┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┓ | ||
┃Column 1 ┃Column 2┃Column 3┃ | ||
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━┩ | ||
│C++ │Web │Assembly│ | ||
├──────────┼────────┼────────┤ | ||
│Javascript│CSS │HTML │ | ||
└──────────┴────────┴────────┘ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode with double header"} > should translate a simple table 1`] = ` | ||
"╒══════════╤════════╤════════╕ | ||
│Column 1 │Column 2│Column 3│ | ||
╞══════════╪════════╪════════╡ | ||
│C++ │Web │Assembly│ | ||
├──────────┼────────┼────────┤ | ||
│Javascript│CSS │HTML │ | ||
└──────────┴────────┴────────┘ | ||
" | ||
`; | ||
|
||
exports[`Table expression translation > With options {"style":"unicode"} > should translate a simple table 1`] = ` | ||
"┌──────────┬────────┬────────┐ | ||
│Column 1 │Column 2│Column 3│ | ||
├──────────┼────────┼────────┤ | ||
│C++ │Web │Assembly│ | ||
├──────────┼────────┼────────┤ | ||
│Javascript│CSS │HTML │ | ||
└──────────┴────────┴────────┘ | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.