Giter Club home page Giter Club logo

big5-ansiart's Introduction

AnsiArt

This project is under refactoring.

Pending issues:

  • Currently it only supports Ruby 1.9.2 or above because it uses String#encode!
  • It requires uming.ttc font file in current working directory. This is inconvenient.
  • The CSS should be moved somewhere else.
  • Do we need to refine API of AnsiArt::Document. It should be the only API class. All other classes are for internal use. It's nice if we can make its API as generic as possible.

I saw there are some code to use gd2 gem in ruby 1.8.x. I think that doesn't work.

Requirement

  • Ruby 1.9.2 or above
  • libgd

Installation

It's not on rubygems.org yet. Just clone the git reposiory and execute.

rake install

Example: Get it working

This gem requires CJK font AR PL UMing for PNG rendering, which is licensed under Arphic Public License. Put a uming.tcc font file in your working directory.

Ways to find it:

Download a ansi file:

wget http://ansi.loli.tw/ansiarts/static/803.ans

And here is the ruby snippet:

require 'rubygems'
gem 'ansi_art'
require 'ansi_art'

doc = AnsiArt::Document.new(IO.read('803.ans'))
File.open('out.html', 'w') { |f| f.write(doc.to_html) }
File.open('out.png', 'wb') { |f| f.write(doc.to_png) }

You should see out.html and out.png in your working directory.

Make HTML display correctly

HTML output needs to be wraped under a <div class="ansi-block"> tag, and apply required css files.

Example:

<!doctype html>
<html>
<head>
    <title>ANSI art test page</title>
    <link href="ansi.css" rel="stylesheet" type="text/css">
    <!--[if IE 9]>
    <link href="ansi.ie9.css" rel="stylesheet" type="text/css">
    <![endif]-->
</head>
<body>
    <div class="ansi-block">
	<%= c.to_html %>
    </div>
</body>
</html>

big5-ansiart's People

Contributors

miaout17 avatar albb0920 avatar

Watchers

James Cloos avatar

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.