commit
4f9981cd83
|
@ -6,6 +6,7 @@
|
|||
|
||||
# v0.29.0
|
||||
- Closes [#447](https://github.com/Glavin001/atom-beautify/issues/447). Improved Handlebars language support
|
||||
- Closes [#384](https://github.com/Glavin001/atom-beautify/issues/384). Add [latexindent.pl](https://github.com/cmhughes/latexindent.pl) beautifier for LaTeX language
|
||||
|
||||
# v0.26.0 (2015-05-03)
|
||||
- Closes [#176](https://github.com/Glavin001/atom-beautify/issues/176). Add [gofmt](http://golang.org/cmd/gofmt/) beautifier for Go language
|
||||
|
|
416
docs/options.md
416
docs/options.md
|
@ -1848,6 +1848,185 @@ If a terminating comma should be inserted into arrays, object literals, and dest
|
|||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Indent char](#latex---indent-char)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `indent_char`
|
||||
|
||||
**Default**: ` `
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Indentation character (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"indent_char": " "
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Indent with tabs](#latex---indent-with-tabs)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `indent_with_tabs`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"indent_with_tabs": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Indent preamble](#latex---indent-preamble)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `indent_preamble`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Indent the preable (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"indent_preamble": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Always look for split braces](#latex---always-look-for-split-braces)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `always_look_for_split_braces`
|
||||
|
||||
**Default**: `true`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
If `latexindent` should look for commands that split braces across lines (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"always_look_for_split_braces": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Always look for split brackets](#latex---always-look-for-split-brackets)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `always_look_for_split_brackets`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
If `latexindent` should look for commands that split brackets across lines (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"always_look_for_split_brackets": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Remove trailing whitespace](#latex---remove-trailing-whitespace)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `remove_trailing_whitespace`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Remove trailing whitespace (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"remove_trailing_whitespace": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Align columns in environments](#latex---align-columns-in-environments)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `align_columns_in_environments`
|
||||
|
||||
**Default**: `tabular,matrix,bmatrix,pmatrix`
|
||||
|
||||
**Type**: `array`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
undefined (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"align_columns_in_environments": [
|
||||
"tabular",
|
||||
"matrix",
|
||||
"bmatrix",
|
||||
"pmatrix"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [Markdown - Gfm](#markdown---gfm)
|
||||
|
||||
**Namespace**: `markdown`
|
||||
|
@ -3748,6 +3927,61 @@ Automatically beautify JSX files on save
|
|||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - JSX - Beautify On Save*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - LaTeX - Disable Beautifying Language](#language-config---latex---disable-beautifying-language)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Description**:
|
||||
|
||||
Disable LaTeX Beautification
|
||||
|
||||
**How to Configure**
|
||||
|
||||
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
|
||||
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
|
||||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - LaTeX - Disable Beautifying Language*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - LaTeX - Default Beautifier](#language-config---latex---default-beautifier)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
||||
**Default**: `Latex Beautify`
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Enum**: `Latex Beautify`
|
||||
|
||||
**Description**:
|
||||
|
||||
Default Beautifier to be used for LaTeX
|
||||
|
||||
**How to Configure**
|
||||
|
||||
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
|
||||
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
|
||||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - LaTeX - Default Beautifier*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - LaTeX - Beautify On Save](#language-config---latex---beautify-on-save)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Description**:
|
||||
|
||||
Automatically beautify LaTeX files on save
|
||||
|
||||
**How to Configure**
|
||||
|
||||
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
|
||||
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
|
||||
2. Go into *Packages* and search for "*Atom Beautify*" package.
|
||||
3. Find the option "*Language Config - LaTeX - Beautify On Save*" and change it to your desired configuration.
|
||||
|
||||
#### [Language Config - LESS - Disable Beautifying Language](#language-config---less---disable-beautifying-language)
|
||||
|
||||
**Important**: This option is only configurable from within Atom Beautify's setting panel.
|
||||
|
@ -7225,6 +7459,188 @@ Path to the emacs script (Supported by Fortran Beautifier)
|
|||
```
|
||||
|
||||
|
||||
### Latex Beautify
|
||||
|
||||
#### [LaTeX - Indent char](#latex---indent-char)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `indent_char`
|
||||
|
||||
**Default**: ` `
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Indentation character (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"indent_char": " "
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Indent with tabs](#latex---indent-with-tabs)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `indent_with_tabs`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"indent_with_tabs": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Indent preamble](#latex---indent-preamble)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `indent_preamble`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Indent the preable (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"indent_preamble": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Always look for split braces](#latex---always-look-for-split-braces)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `always_look_for_split_braces`
|
||||
|
||||
**Default**: `true`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
If `latexindent` should look for commands that split braces across lines (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"always_look_for_split_braces": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Always look for split brackets](#latex---always-look-for-split-brackets)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `always_look_for_split_brackets`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
If `latexindent` should look for commands that split brackets across lines (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"always_look_for_split_brackets": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Remove trailing whitespace](#latex---remove-trailing-whitespace)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `remove_trailing_whitespace`
|
||||
|
||||
**Type**: `boolean`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
Remove trailing whitespace (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"remove_trailing_whitespace": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### [LaTeX - Align columns in environments](#latex---align-columns-in-environments)
|
||||
|
||||
**Namespace**: `latex`
|
||||
|
||||
**Key**: `align_columns_in_environments`
|
||||
|
||||
**Default**: `tabular,matrix,bmatrix,pmatrix`
|
||||
|
||||
**Type**: `array`
|
||||
|
||||
**Supported Beautifiers**: [`Latex Beautify`](#latex-beautify)
|
||||
|
||||
**Description**:
|
||||
|
||||
undefined (Supported by Latex Beautify)
|
||||
|
||||
**Example `.jsbeautifyrc` Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"latex": {
|
||||
"align_columns_in_environments": [
|
||||
"tabular",
|
||||
"matrix",
|
||||
"bmatrix",
|
||||
"pmatrix"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Remark
|
||||
|
||||
#### [Markdown - Gfm](#markdown---gfm)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
This is a sample.
|
||||
\[
|
||||
\int_0^1f(x)\, dx
|
||||
\]
|
||||
The above should be indented.
|
|
@ -0,0 +1,5 @@
|
|||
This is a sample.
|
||||
\[
|
||||
\int_0^1f(x)\, dx
|
||||
\]
|
||||
The above should be indented.
|
|
@ -66,6 +66,10 @@
|
|||
{
|
||||
"name": "Luis Arias",
|
||||
"url": "https://github.com/kaaloo"
|
||||
},
|
||||
{
|
||||
"name": "Bati Sengul",
|
||||
"url": "https://github.com/Focus"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
|
|
|
@ -44,6 +44,7 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
'csscomb'
|
||||
'gherkin'
|
||||
'gofmt'
|
||||
'latex-beautify'
|
||||
'fortran-beautifier'
|
||||
'js-beautify'
|
||||
'jscs'
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
path = require('path')
|
||||
fs = require("fs")
|
||||
temp = require("temp").track()
|
||||
|
||||
|
||||
module.exports = class LatexBeautify extends Beautifier
|
||||
name: "Latex Beautify"
|
||||
|
||||
options: {
|
||||
LaTeX: true
|
||||
}
|
||||
|
||||
# There are too many options with latexmk, I have tried to slim this down to the most useful ones.
|
||||
# This method creates a configuration file for latexindent.
|
||||
buildConfigFile: (options) ->
|
||||
indentChar = options.indent_char
|
||||
if options.indent_with_tabs
|
||||
indentChar = "\\t"
|
||||
# +true = 1 and +false = 0
|
||||
config = """
|
||||
defaultIndent: \"#{indentChar}\"
|
||||
alwaysLookforSplitBraces: #{+options.always_look_for_split_braces}
|
||||
alwaysLookforSplitBrackets: #{+options.always_look_for_split_brackets}
|
||||
indentPreamble: #{+options.indent_preamble}
|
||||
removeTrailingWhitespace: #{+options.remove_trailing_whitespace}
|
||||
lookForAlignDelims:\n
|
||||
"""
|
||||
for delim in options.align_columns_in_environments
|
||||
config += "\t#{delim}: 1\n"
|
||||
return config
|
||||
|
||||
# Latexindent accepts configuration _files_ only.
|
||||
# This file has to be named localSettings.yaml and be in the same folder as the tex file.
|
||||
# It also insists on creating a log file somewhere.
|
||||
# So we set up a directory with all the files in place.
|
||||
setUpDir: (dirPath, text, config) ->
|
||||
@texFile = path.join(dirPath, "latex.tex")
|
||||
fs.writeFile @texFile, text, (err) ->
|
||||
return reject(err) if err
|
||||
@configFile = path.join(dirPath, "localSettings.yaml")
|
||||
fs.writeFile @configFile, config, (err) ->
|
||||
return reject(err) if err
|
||||
@logFile = path.join(dirPath, "indent.log")
|
||||
fs.writeFile @logFile, "", (err) ->
|
||||
return reject(err) if err
|
||||
|
||||
#Beautifier does not currently have a method for creating directories, so we call temp directly.
|
||||
beautify: (text, language, options) ->
|
||||
new @Promise((resolve, reject) ->
|
||||
temp.mkdir("latex", (err, dirPath) ->
|
||||
return reject(err) if err
|
||||
resolve(dirPath)
|
||||
)
|
||||
)
|
||||
.then((dirPath)=>
|
||||
@setUpDir(dirPath, text, @buildConfigFile(options))
|
||||
run = @run "latexindent", [
|
||||
"-o" #Output to the same location as file, -w creates a backup file, whereas this does not
|
||||
"-s" #Silent mode
|
||||
"-l" #Tell latexindent we have a local configuration file
|
||||
"-c=" + dirPath #Tell latexindent to place the log file in this directory
|
||||
@texFile
|
||||
@texFile
|
||||
], help: {
|
||||
link: "https://github.com/cmhughes/latexindent.pl"
|
||||
}
|
||||
)
|
||||
.then( =>
|
||||
@readFile(@texFile)
|
||||
)
|
|
@ -36,6 +36,7 @@ module.exports = class Languages
|
|||
"javascript"
|
||||
"json"
|
||||
"jsx"
|
||||
"latex"
|
||||
"less"
|
||||
"markdown"
|
||||
'marko'
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
# Get Atom defaults
|
||||
scope = ['source.js']
|
||||
tabLength = atom?.config.get('editor.tabLength', scope: scope) ? 4
|
||||
softTabs = atom?.config.get('editor.softTabs', scope: scope) ? true
|
||||
defaultIndentSize = (if softTabs then tabLength else 1)
|
||||
defaultIndentChar = (if softTabs then " " else "\t")
|
||||
defaultIndentWithTabs = not softTabs
|
||||
|
||||
module.exports = {
|
||||
|
||||
name: "LaTeX"
|
||||
namespace: "latex"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"LaTeX"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"tex"
|
||||
]
|
||||
|
||||
defaultBeautifier: "Latex Beautify"
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
options:
|
||||
indent_char:
|
||||
type: 'string'
|
||||
default: defaultIndentChar
|
||||
description: "Indentation character"
|
||||
indent_with_tabs:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "Indentation uses tabs, overrides `Indent Size` and `Indent Char`"
|
||||
indent_preamble:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Indent the preable"
|
||||
always_look_for_split_braces:
|
||||
type: 'boolean'
|
||||
default: true
|
||||
description: "If `latexindent` should look for commands that split braces across lines"
|
||||
always_look_for_split_brackets:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "If `latexindent` should look for commands that split brackets across lines"
|
||||
remove_trailing_whitespace:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: "Remove trailing whitespace"
|
||||
align_columns_in_environments:
|
||||
type: 'array'
|
||||
default:["tabular", "matrix", "bmatrix", "pmatrix"]
|
||||
decription: "Aligns columns by the alignment tabs for environments specified"
|
||||
}
|
Loading…
Reference in New Issue