An implement of transform.Transformer to change text style. For example, Gopher to πΎπ π‘πππ£, π²πππππ and so on.
This package is on proof of concept stage. There would be some breaking changes. Do not use this on your products.
This package provides some implementations of transform.Transformer. Combining with transform.Reader enables you to accept any kind of io.Reader to transform text styles.
Here is a simple example.
package main
import (
"io"
"os"
"strings"
"github.com/tenkoh/go-textstyle"
"golang.org/x/text/transform"
)
func main() {
s := "Hello, Gophers"
r := transform.NewReader(strings.NewReader(s), textstyle.Bold())
io.Copy(os.Stdout, r)
//Output: πππ₯π₯π¨, ππ¨π©π‘ππ«π¬
}
You can use other io.Reader like os.Stdin, *os.File, http.Response.Body and so on.
- Bold
- Italic
- BoldItalic
- Script
- BoldScript
- Fraktur
- BoldFraktur
- DoubleStruck
- SansSerif
- SansSerifBold
- SansSerifItalic
- SansSerifBoldItalic
- Monospce
I'm very welcome your contribution. There are some assets to help adding text styles. If you are eager to add a complex transformation, do it your way without the assets.
If you want to add simple replacement, which means just giving codepoint offsets, you can use code generation tool. Please open generate_style.go
, then add Style
refering to existing styles. After editting, go generate
command generates styles.go
including added styles.
Unicode table has some lacks (or reserved part) to alphabets. If you can not realize simple repalcement due to a few excepts, please consider to add a pairs to alternate them into altMap
in textstyle.go
.
- 0.0.1: Basic functions and some styles (current)
- 0.0.x: Add Greek styles and enclosed styles.
I was very impressed by https://github.com/ikanago/omekasy , CLI tool to change text style implemented in Rust.
MIT
tenkoh