Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.5 KiB

  1. # cardinal [![Build Status](https://secure.travis-ci.org/thlorenz/cardinal.svg)](http://travis-ci.org/thlorenz/cardinal)
  2. <a href="https://www.patreon.com/bePatron?u=8663953"><img alt="become a patron" src="https://c5.patreon.com/external/logo/become_a_patron_button.png" height="35px"></a>
  3. [![NPM](https://nodei.co/npm/cardinal.png?downloads=true&stars=true)](https://nodei.co/npm/cardinal/)
  4. **car·di·nal** *(kärdn-l, kärdnl)* - crested thick-billed North American finch having bright red plumage in the male.
  5. ![screenshot](https://github.com/thlorenz/cardinal/raw/master/assets/screen-shot.png)
  6. ## Features
  7. - highlights JavaScript code with ANSI colors to improve terminal output
  8. - theming support, see [custom color themes](https://github.com/thlorenz/cardinal/tree/master/themes)
  9. - optionally print line numbers
  10. - API and command line interface (`cdl`)
  11. - `.cardinalrc` config to customize settings
  12. - supports UNIX pipes
  13. ***
  14. **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
  15. - [Installation](#installation)
  16. - [As library](#as-library)
  17. - [As Commandline Tool](#as-commandline-tool)
  18. - [Commandline](#commandline)
  19. - [Highlight a file](#highlight-a-file)
  20. - [As part of a UNIX pipe](#as-part-of-a-unix-pipe)
  21. - [Theme](#theme)
  22. - [API](#api)
  23. - [*highlight(code[, opts])*](#highlightcode-opts)
  24. - [*highlightFileSync(fullPath[, opts])*](#highlightfilesyncfullpath-opts)
  25. - [*highlightFile(fullPath[, opts], callback)*](#highlightfilefullpath-opts-callback)
  26. - [opts](#opts)
  27. - [Examples ([*browse*](https://github.com/thlorenz/cardinal/tree/master/examples))](#examples-[browse]https://githubcom/thlorenz/cardinal/tree/master/examples)
  28. ## Installation
  29. ### As library
  30. npm install cardinal
  31. ### As Commandline Tool
  32. [sudo] npm install -g cardinal
  33. **Note:**
  34. When installed globally, cardinal exposes itself as the `cdl` command.
  35. ## Commandline
  36. ### Highlight a file
  37. cdl <file.js> [options]
  38. **options**:
  39. - `--nonum`: turns off line number printing (relevant if it is turned on inside `~/.cardinalrc`
  40. ### As part of a UNIX pipe
  41. cat file.js | grep console | cdl
  42. **Note:**
  43. Not all code lines may be parsable JavaScript. In these cases the line is printed to the terminal without
  44. highlighting it.
  45. ### Theme
  46. The default theme will be used for highlighting.
  47. To use a different theme, include a `.cardinalrc` file in your `HOME` directory.
  48. This is a JSON file of the following form:
  49. ```json
  50. {
  51. "theme": "hide-semicolons",
  52. "linenos": true|false
  53. }
  54. ```
  55. - `theme` can be the name of any of the [built-in themes](https://github.com/thlorenz/cardinal/tree/master/themes) or the
  56. full path to a custom theme anywhere on your computer.
  57. - linenos toggles line number printing
  58. ## API
  59. ### *highlight(code[, opts])*
  60. - returns the highlighted version of the passed code ({String}) or throws an error if it was not able to parse it
  61. - opts (see below)
  62. ### *highlightFileSync(fullPath[, opts])*
  63. - returns the highlighted version of the file whose fullPath ({String}) was passed or throws an error if it was not able
  64. to parse it
  65. - opts (see below)
  66. ### *highlightFile(fullPath[, opts], callback)*
  67. - calls back with the highlighted version of the file whose fullPath ({String}) was passed or with an error if it was not able
  68. to parse it
  69. - opts (see below)
  70. - `callback` ({Function}) has the following signature: `function (err, highlighted) { .. }`
  71. ### opts
  72. opts is an {Object} with the following properties:
  73. - `theme` {Object} is used to optionally override the theme used to highlight
  74. - `linenos` {Boolean} if `true` line numbers are included in the highlighted code
  75. - `firstline` {Integer} sets line number of the first line when line numbers are printed
  76. - `jsx` {Boolean} if `true` _JSX_ syntax is supported, otherwise cardinal will raise an error
  77. when encountering _JSX_ (default: `false`)
  78. **Note** The `json` option is obsoleted and not necessary anymore as cardinal properly understands both JSON and JavaScript.
  79. ## Examples ([*browse*](https://github.com/thlorenz/cardinal/tree/master/examples))
  80. - [sample .cardinalrc](https://github.com/thlorenz/cardinal/blob/master/examples/.cardinalrc)
  81. - [highlighting a code snippet](https://github.com/thlorenz/cardinal/blob/master/examples/highlight-string.js) via
  82. ***highlight()***
  83. - [file that highlights itself](https://github.com/thlorenz/cardinal/blob/master/examples/highlight-self.js) via
  84. ***highlightFile()*** including line numbers
  85. - [file that highlights itself hiding all
  86. semicolons](https://github.com/thlorenz/cardinal/blob/master/examples/highlight-self-hide-semicolons.js) via
  87. ***highlightFileSync()***