GithubHelp home page GithubHelp logo

nf_test's Introduction

NF.normaliseTableBorders()

Normalise border properties on simple table objects.

Example Table Object

var table = {
    cells: [
        [   
            {
                rowspan: 1,
                colspan: 1,
                border: {
                    top: 'solid',
                    right: 'solid',
                    bottom: 'solid',
                    left: 'solid'
                }
            },
            {
                rowspan: 1,
                colspan: 1,
                border: {
                    top: 'solid',
                    right: 'solid',
                    bottom: 'solid',
                    left: 'solid'
                }
            }
        ],[
            {
                rowspan: 1,
                colspan: 1,
                border: {
                    top: 'solid',
                    right: 'solid',
                    bottom: 'solid',
                    left: 'solid'
                }
            },
            {
                rowspan: 1,
                colspan: 1,
                border: {
                    top: 'solid',
                    right: 'solid',
                    bottom: 'solid',
                    left: 'solid'
                }
            }
        ]
    ]
};

Requirements:

Given is a table with R rows and C columns. Each cell can have a "rowspan" and/or a "colspan". Additionally, on each side of the cell (top, bottom, left, right), a border style can be defined. Possible border styles are (strong, normal, weak, solid, dashed, dotted, none).

The expected output of the algorithm is a normalized set of border information where for each cell, only a top and/or left border is defined. This means that whenever a cell has a right or bottom border, those must be "moved" to the adjacent cells as left or top border.

Whenever border styles are defined on adjacent cells (e.g. cell[1,1] has strong right border and cell[1,2] has dotted left border), the border styles are merged (in the example to strong/dotted). Border style merging follows "common sense" insofar as the strength types (strong, normal, weak) can be merged with the style types (solid, dashed, dotted) but two borders from the same type should result in an error (e.g. a cell with dotted right border must not be adjacent to a cell with a dashed left border).

Using Python SimpleHTTPServer module to run the test suite:

$ cd nf_test/
$ python -m SimpleHTTPServer
To run Jasmine tests navigate your browser to:
http://localhost:8000/tests/SpecRunner.html

nf_test's People

Contributors

tthew 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.