[go: up one dir, main page]

This package has been deprecated

Author message:

this package has been deprecated in favor of prettier-elastic-query

prettier-es

0.0.1 • Public • Published

prettier-es

prettier-es is a library for formatting and highlighting Elasticsearch queries.

prettier-es uses Ohm parser to parse the query and Prism for highlighting it. See demo page for examples or try live editor with your own query.

Getting Started

Installation

If you are using Node.js, you can just install the prettier-es package using npm:

npm install prettier-es

This will install prettier-es in the local node_modules folder. Use require to access it from a Node script:

var prettier = require('prettier-es');

If you want to use prettier-es in a browser, you can download prettier-es.min.js and prettier-es.min.css and reference it in your HTML file.

<link href="resources/prettier-es.min.css" rel="stylesheet" type="text/css"/>
<script src="resources/prettier-es.min.js" type="text/javascript"></script>
<script>
    console.info(PrettierEs.prettify("query text", 80));
</script>

See demo page source for usage example.

API reference

format(query, maxWidth, style) - format ES query, fitting it in maxWidth characters per line and following provided style. Possible style options are lisp and simple, with lisp being used if no style argument provided;

highlight(query) - highlight query with Prism. prettier-es build provides default Prism css theme. You can use any Prism theme, just include theme's css style file in your html file;

prettify(query, maxWidth, style) - format and highlight ES query. Calls format() and highlight() functions inside;

prettifyElement(elementId, showErrors, maxWidth, errorCss) - formats and highlights ES query inplace inside HTML element. showErrors - boolean indicating if error information should be rendered, false by default. errorCss class to be used in error message formatting;

extendHighlighter(keywordsList) - extends Prism highlighter with custom keywords;

markErrorInQuery(query, error, cssClass) - inserts <u> element around offending character in the query. error here is an instance of the error thrown by format function.

Package Sidebar

Install

npm i prettier-es

Weekly Downloads

0

Version

0.0.1

License

BSD-3-Clause

Unpacked Size

4.68 MB

Total Files

22

Last publish

Collaborators

  • traut