Coder Social home page Coder Social logo

liamg / tml Goto Github PK

View Code? Open in Web Editor NEW
731.0 8.0 19.0 55 KB

:rainbow::computer::art: A tiny markup language for terminal output. Makes formatting output in CLI apps easier!

License: The Unlicense

Go 95.18% Makefile 4.82%
terminal tui terminal-ui colours colors cli cli-app

tml's Introduction

tml - Terminal Markup Language

Build Status GoDoc

A Go module (and standalone binary) to make the output of coloured/formatted text in the terminal easier and more readable.

You can use it in your Go programs, and bash etc. too.

Example screenshot

Usage in Go

The output of coloured/formatted text is easy using the following syntax:

package main

import "github.com/liamg/tml"

func main() {
    tml.Printf("<red>this text is <bold>red</bold></red> and the following is <green>%s</green>\n", "not red")
}

Usage in Bash

First, install tml:

Install Go and run the following command.

# For Go 1.16+
# Make sure that `$GOPATH/bin` is in your `$PATH`, because that's where this gets installed

go install github.com/liamg/tml/tml@latest

# For Go <1.16

go get -u github.com/liamg/tml/tml

Then you can simply pipe text containing tags to tml:

#!/bin/bash

echo "<red>this text is <bold>red</bold></red> and the following is <green>not red</green>" | tml

Format

Each tag is enclosed in angle brackets, much like HTML.

You can nest tags as deeply as you like.

It's not required to close tags you've opened, though it can make for easier reading.

Available Tags

Foreground Colours

  • <red>
  • <green>
  • <yellow>
  • <blue>
  • <magenta>
  • <cyan>
  • <lightgrey>
  • <darkgrey>
  • <black>
  • <white>
  • <lightred>
  • <lightgreen>
  • <lightyellow>
  • <lightblue>
  • <lightmagenta>
  • <lightcyan>

Background Colours

  • <bg-red>
  • <bg-green>
  • <bg-yellow>
  • <bg-blue>
  • <bg-magenta>
  • <bg-cyan>
  • <bg-lightgrey>
  • <bg-darkgrey>
  • <bg-black>
  • <bg-white>
  • <bg-lightred>
  • <bg-lightgreen>
  • <bg-lightyellow>
  • <bg-lightblue>
  • <bg-lightmagenta>
  • <bg-lightcyan>

Attributes

  • <bold>
  • <dim>
  • <italic>
  • <underline>
  • <blink>
  • <reverse>
  • <hidden>
  • <strikethrough>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.