zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

README.md (4142B)


      1 # Makeup
      2 
      3 [![Module Version](https://img.shields.io/hexpm/v/makeup.svg)](https://hex.pm/packages/makeup)
      4 [![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/makeup/)
      5 
      6 ## Introduction
      7 
      8 Makeup is a "generic syntax highlighter suitable for use in code hosting, forums, wikis or other applications that need to prettify source code" . This tagline was shamelessly stolen from the [Pygments website](http://pygments.org/).
      9 
     10 Pygments the major inspiration for this package, and the structure is basically the same.
     11 It has **lexers**, **formatters** and **styles**.
     12 
     13 * **Lexers** turn the source code into a list of tokens.
     14 * **Formatters** turn the list of tokens into something else (HTML, TeX, images, etc.).
     15   Currently only an HTML formatter exists.
     16 * **Styles** customize the output of the formatter.
     17   Makeup supports all Pygments' styles (in fact, they were converted from the Python's source).
     18   New custom styles can be added to makeup itself, or defined in the Project that uses it.
     19 
     20 ## Demo
     21 
     22 To see a sample of Makeup's output, go check the [demo](https://tmbb.github.io/makeup_demo/).
     23 Please note that not all styles define all differences between tokens.
     24 In a given style, strings and characters might be rendered in the same color while in others , the colors might be different.
     25 
     26 That is style-dependent.
     27 
     28 Some of the richer styles are
     29 the Tango style ([elixir](https://tmbb.github.io/makeup_demo/elixir.html#tango)),
     30 the Colorful style ([elixir](https://tmbb.github.io/makeup_demo/elixir.html#colorful)),
     31 the Default style ([elixir](https://tmbb.github.io/makeup_demo/elixir.html#default)), and
     32 the Friendly style ([elixir](https://tmbb.github.io/makeup_demo/elixir.html#friendly)).
     33 
     34 ## Supported Languages
     35 
     36 The supported source languages are:
     37 
     38   * [Elixir](https://github.com/tmbb/makeup_elixir)
     39   * [Erlang](https://github.com/tmbb/makeup_erlang)
     40   * [C](https://github.com/boydm/makeup_c)
     41 
     42 ## Installation
     43 
     44 The package can be installed by adding `makeup` and `makeup_elixir` (required
     45 for the ElixirLexer) to your list of dependencies in `mix.exs`:
     46 
     47 ```elixir
     48 def deps do
     49   [
     50     {:makeup, "x.y.z"},
     51     {:makeup_elixir, "x.y.z"}
     52   ]
     53 end
     54 ```
     55 
     56 Documentation can be found at [https://hexdocs.pm/makeup](https://hexdocs.pm/makeup).
     57 
     58 ## Changes
     59 
     60 Changes from previous versions are details in the [Changelog](CHANGELOG.md).
     61 
     62 ## Quickstart
     63 
     64 To highlight some Elixir code (newlines added for clarity):
     65 
     66 ```elixir
     67 Makeup.highlight(source)
     68 # "<pre class=\"highlight\"><code>
     69 #   <span class=\"n\">x</span><span class=\"w\"> </span>
     70 #   <span class=\"o\">+</span><span class=\"w\"> </span><span class=\"mi\">1</span>
     71 # </code></pre>\n"
     72 ```
     73 
     74 As you can see, the default HTML formatter uses CSS classes.
     75 You'll need a CSS stylesheet to get the different colors and styles.
     76 
     77 To generate a stylesheet:
     78 
     79 ```
     80 Makeup.stylesheet(style) # by default, the StyleMap.default style is used.
     81 # ... output omitted
     82 ```
     83 
     84 ## Advantages over Pygments
     85 
     86 One of the greatest advantages is that it runs on the BEAM, so it can be used with Elixir projects without external dependencies.
     87 
     88 Another advantage is that the way lexers are written, we can be a lot smarter than Pygments in processing the output.
     89 
     90 For the developer, lexers are also easier to write than the Pygments lexers, because we use a PEG parser.
     91 Most Pygments lexers use something like a state table that works based on regex matches,
     92 and uses the results of those matches to switch to another state.
     93 Using a PEG parser we can define the grammar in a more natural way.
     94 
     95 
     96 The lexers are written using the excellent [NimbleParsec](https://github.com/dashbitco/nimble_parsec) parser.
     97 
     98 ## Disadvantages over Pygments
     99 
    100 It supports fewer languages.
    101 
    102 ## Documentation on how to write a new lexer
    103 
    104 Contributions are highly appreciated. The most direct way you can contribute to Makeup is by writing a new lexer. You can find some information here: [CONTRIBUTING.md](CONTRIBUTING.md)
    105 
    106 ## LICENSE
    107 
    108 Makeup is licensed under the BSD license.
    109 This is the same license as the Pygments Makeup uses and
    110 it seems to be compatible with the licenses used by all the dependencies.