Giter VIP home page Giter VIP logo

elm-ansi's Introduction

elm-ansi

ANSI text stream handling for Elm.

Usage

Parsing a string of ANSI console output

The Ansi.parse function returns a list of Ansi.Action types which can be used for interpreting escape sequences:

> Ansi.parse "\u{001b}[1;32mhello\u{001b}[0m"
[SetBold True,SetForeground (Just Green),Print "hello",SetForeground Nothing,SetBackground Nothing,SetBold False,SetFaint False,SetItalic False,SetUnderline False,SetBlink False,SetInverted False,SetFraktur False,SetFramed False]
    : List Ansi.Action

The Ansi.parseInto function calls a helper function while parsing to avoid the intermediate data structure.

Rendering ANSI console output as HTML

The Ansi.Log module provides a component for incrementally parsing String chunks and maintaining a Model that can be rendered as HTML.

It exports the usual init, update, view along with Model and other types to assist with rendering, should you want to bring your own view function. A viewLine function is also exported should you want to re-use that aspect within your own view.

elm-ansi's People

Contributors

dependabot[bot] avatar evanphx avatar evanradcliffe avatar mhuangpivotal avatar vito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

elm-ansi's Issues

inspec's "green" output displays as flashing red

As a more minimal test case, try printf '\033[38;5;41m hello world\033[0m\n' or this concourse task-

---
platform: linux

run:
  path: /usr/local/bin/bash
  args: ['-c', "printf '\\033[38;5;41m hello world\\033[0m\\n'"]

image_resource:
  type: docker-image
  source:
    repository: bash

in the Concourse discord, vito indicated it was probably 256-bit color related-

vito: @hfinucane you can open a bug on https://github.com/vito/elm-ansi - looks like it's missing 256-color support

Related tickets: inspec/inspec#1700 jenkinsci/ansicolor-plugin#96

Implement correct handling of ECMA-48 sequences

Problem

'ANSI' color sequences are only a small part of a larger spec. Other unsupported escape sequences should be stripped.

Spec

According to https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#backward-compatibility this library doesn't implements parsing according to ECMA-48

Since it deals with 7bit vs 8bit escape sequences that is one dense spec...

  • The relevant section is ^] 8.3.89 OSC - OPERATING SYSTEM COMMAND
  • Color is part of 8.3.16 CSI - CONTROL SEQUENCE INTRODUCER ^[
  • Both sequences (and a fair number of other sequences) are ended 8.3.143 ST - STRING TERMINATOR

see concourse/concourse#4318

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.