From 70b2bd0d1fe4b5a6d345db8a8de0a4f11d682a9c Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Thu, 28 Oct 2021 11:33:33 +0700 Subject: [PATCH] feat: support more input --- .github/codegen.js | 14 +- README.txt | 2 +- asciitxt_test.go | 12 +- standard.go | 351 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 369 insertions(+), 10 deletions(-) diff --git a/.github/codegen.js b/.github/codegen.js index 0bb0c67..917fc0f 100644 --- a/.github/codegen.js +++ b/.github/codegen.js @@ -7,12 +7,12 @@ const fs = require('fs/promises'); // the letters array just to be a single value. const letters = [ -` - __ _ - / _\` | - | (_| | - \\__,_| - `, +` _ + (_) + | | + | | + |_| + `, ] ;(async () => { @@ -26,5 +26,5 @@ const letters = } output += "}\n"; } - await fs.writeFile('./../generated.go', output, { encoding: 'utf-8' }); + await fs.writeFile('./generated.go', output, { encoding: 'utf-8' }); })(); \ No newline at end of file diff --git a/README.txt b/README.txt index f2fa627..3536d3a 100644 --- a/README.txt +++ b/README.txt @@ -35,7 +35,7 @@ The usage is pretty straight forward, on your Go file: // or - output = asciitxt.WithConfig("Hello world", &asciitxt.Config{ + output = asciitxt.WithConfig("Hello world", asciitxt.Config{ Style: asciitxt.StyleStandard, }) } diff --git a/asciitxt_test.go b/asciitxt_test.go index 58b5b63..53bb99b 100644 --- a/asciitxt_test.go +++ b/asciitxt_test.go @@ -7,14 +7,22 @@ import ( ) func TestNew(t *testing.T) { - s := asciitxt.New("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 _ the quick brown fox jumps over the lazy dog") + s := asciitxt.New("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 æ` the quick brown fox jumps over the lazy dog") if s == "" { t.Error("should not be empty") } } func TestWithConfig(t *testing.T) { - s := asciitxt.WithConfig("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 _ the quick brown fox jumps over the lazy dog", asciitxt.Config{}) + s := asciitxt.WithConfig("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 æ` the quick brown fox jumps over the lazy dog", asciitxt.Config{}) + + if s == "" { + t.Error("should not be empty") + } +} + +func TestSymbols(t *testing.T) { + s := asciitxt.WithConfig(`!"#$%&'()*+,-./:;<=>?[\]^_{|}~¡¢£¥¨§©±`, asciitxt.Config{Style: asciitxt.StyleStandard}) if s == "" { t.Error("should not be empty") diff --git a/standard.go b/standard.go index 5ed8e91..389b164 100644 --- a/standard.go +++ b/standard.go @@ -572,6 +572,357 @@ func getStandardLetter(letter string) []string { ` `, ` `, } + case "+": + return []string{ + ` `, + ` _ `, + ` _| |_ `, + ` |_ _|`, + ` |_| `, + ` `, + } + case "-": + return []string{ + ` `, + ` `, + ` _____ `, + ` |_____|`, + ` `, + ` `, + } + case "_": + return []string{ + ` `, + ` `, + ` `, + ` `, + ` _____ `, + ` |_____|`, + } + case "=": + return []string{ + ` `, + ` _____ `, + ` |_____|`, + ` |_____|`, + ` `, + ` `, + } + case "!": + return []string{ + ` _ `, + ` | |`, + ` | |`, + ` |_|`, + ` (_)`, + ` `, + } + case "@": + return []string{ + ` ____ `, + ` / __ \ `, + " / / _` |", + ` | | (_| |`, + ` \ \__,_|`, + ` \____/ `, + } + case "#": + return []string{ + ` _ _ `, + ` _| || |_ `, + ` |_ .. _|`, + ` |_ _|`, + ` |_||_| `, + ` `, + } + case "$": + return []string{ + ` _ `, + ` | | `, + ` / __)`, + ` \__ \`, + ` ( /`, + ` |_| `, + } + case "%": + return []string{ + ` _ __`, + ` (_)/ /`, + ` / / `, + ` / /_ `, + ` /_/(_)`, + ` `, + } + case "^": + return []string{ + ` /\ `, + ` |/\|`, + ` `, + ` `, + ` `, + ` `, + } + case "&": + return []string{ + ` ___ `, + ` ( _ ) `, + ` / _ \/\`, + ` | (_> <`, + ` \___/\/`, + ` `, + } + case "*": + return []string{ + ` `, + ` __/\__`, + ` \ /`, + ` /_ _\`, + ` \/ `, + ` `, + } + case "(": + return []string{ + ` __`, + ` / /`, + ` | | `, + ` | | `, + ` | | `, + ` \_\`, + } + case ")": + return []string{ + ` __ `, + ` \ \ `, + ` | |`, + ` | |`, + ` | |`, + ` /_/ `, + } + case ",": + return []string{ + ` `, + ` `, + ` `, + ` _ `, + ` ( )`, + ` |/ `, + } + case ".": + return []string{ + ` `, + ` `, + ` `, + ` _ `, + ` (_)`, + ` `, + } + case "<": + return []string{ + ` __`, + ` / /`, + ` / / `, + ` \ \ `, + ` \_\`, + ` `, + } + case ">": + return []string{ + ` __ `, + ` \ \ `, + ` \ \`, + ` / /`, + ` /_/ `, + ` `, + } + case "?": + return []string{ + ` ___ `, + ` |__ \`, + ` / /`, + ` |_| `, + ` (_) `, + ` `, + } + case "/": + return []string{ + ` __`, + ` / /`, + ` / / `, + ` / / `, + ` /_/ `, + ` `, + } + case ";": + return []string{ + ` `, + ` _ `, + ` (_)`, + ` _ `, + ` ( )`, + ` |/ `, + } + case ":": + return []string{ + ` `, + ` _ `, + ` (_)`, + ` _ `, + ` (_)`, + ` `, + } + case "'": + return []string{ + ` _ `, + ` ( )`, + ` |/ `, + ` `, + ` `, + ` `, + } + case "\"": + return []string{ + ` _ _ `, + ` ( | )`, + ` V V `, + ` `, + ` `, + ` `, + } + case "[": + return []string{ + ` __ `, + ` | _|`, + ` | | `, + ` | | `, + ` | | `, + ` |__|`, + } + case "]": + return []string{ + ` __ `, + ` |_ |`, + ` | |`, + ` | |`, + ` | |`, + ` |__|`, + } + case "{": + return []string{ + ` __`, + ` / /`, + ` | | `, + ` < < `, + ` | | `, + ` \_\`, + } + case "}": + return []string{ + ` __ `, + ` \ \ `, + ` | | `, + ` > >`, + ` | | `, + ` /_/ `, + } + case "\\": + return []string{ + ` __ `, + ` \ \ `, + ` \ \ `, + ` \ \ `, + ` \_\`, + ` `, + } + case "|": + return []string{ + ` _ `, + ` | |`, + ` | |`, + ` | |`, + ` | |`, + ` |_|`, + } + case "`": + return []string{ + ` _ `, + ` ( )`, + ` \|`, + ` `, + ` `, + ` `, + } + case "~": + return []string{ + ` /\/|`, + ` |/\/ `, + ` `, + ` `, + ` `, + ` `, + } + case "¡": + return []string{ + ` _ `, + ` (_)`, + ` | |`, + ` | |`, + ` |_|`, + ` `, + } + case "¢": + return []string{ + ` _ `, + ` | | `, + ` / __)`, + ` | (__ `, + ` \ )`, + ` |_| `, + } + case "£": + return []string{ + ` ___ `, + ` / ,_\ `, + ` _| |_ `, + ` | |___ `, + ` (_,____|`, + ` `, + } + case "¥": + return []string{ + ` __ __ `, + ` \ V / `, + ` |__ __|`, + ` |__ __|`, + ` |_| `, + ` `, + } + case "©": + return []string{ + ` _____ `, + ` / ___ \ `, + ` / / __| \ `, + ` | | (__ |`, + ` \ \___| / `, + ` \_____/ `, + } + case "±": + return []string{ + ` _ `, + ` _| |_ `, + ` |_ _|`, + ` _|_|_ `, + ` |_____|`, + ` `, + } + case "§": + return []string{ + ` __ `, + ` _/ _)`, + ` / \ \ `, + ` \ \\ \`, + ` \ \_/`, + ` (__/ `, + } default: return []string{ ``,