mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Merge pull request #18014 from atom/migrate-autoflow-package
➡️ Migrate core package 'autoflow' into ./packages
This commit is contained in:
1842
package-lock.json
generated
1842
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@
|
||||
"autocomplete-html": "https://www.atom.io/api/packages/autocomplete-html/versions/0.8.6/tarball",
|
||||
"autocomplete-plus": "https://www.atom.io/api/packages/autocomplete-plus/versions/2.41.0/tarball",
|
||||
"autocomplete-snippets": "https://www.atom.io/api/packages/autocomplete-snippets/versions/1.12.0/tarball",
|
||||
"autoflow": "https://www.atom.io/api/packages/autoflow/versions/0.29.4/tarball",
|
||||
"autoflow": "file:packages/autoflow",
|
||||
"autosave": "https://www.atom.io/api/packages/autosave/versions/0.24.6/tarball",
|
||||
"babel-core": "5.8.38",
|
||||
"background-tips": "https://www.atom.io/api/packages/background-tips/versions/0.28.0/tarball",
|
||||
@@ -190,7 +190,7 @@
|
||||
"autocomplete-html": "0.8.6",
|
||||
"autocomplete-plus": "2.41.0",
|
||||
"autocomplete-snippets": "1.12.0",
|
||||
"autoflow": "0.29.4",
|
||||
"autoflow": "file:./packages/autoflow",
|
||||
"autosave": "0.24.6",
|
||||
"background-tips": "0.28.0",
|
||||
"bookmarks": "0.45.1",
|
||||
|
||||
@@ -18,7 +18,7 @@ See [RFC 003](https://github.com/atom/atom/blob/master/docs/rfcs/003-consolidate
|
||||
| **autocomplete-html** | [`atom/autocomplete-html`][autocomplete-html] | |
|
||||
| **autocomplete-plus** | [`atom/autocomplete-plus`][autocomplete-plus] | |
|
||||
| **autocomplete-snippets** | [`atom/autocomplete-snippets`][autocomplete-snippets] | |
|
||||
| **autoflow** | [`atom/autoflow`][autoflow] | [#17833](https://github.com/atom/atom/issues/17833) |
|
||||
| **autoflow** | [`atom/autoflow`][./autoflow] | [#17833](https://github.com/atom/atom/issues/17833) |
|
||||
| **autosave** | [`atom/autosave`][autosave] | [#17834](https://github.com/atom/atom/issues/17834) |
|
||||
| **background-tips** | [`atom/background-tips`][background-tips] | [#17835](https://github.com/atom/atom/issues/17835) |
|
||||
| **base16-tomorrow-dark-theme** | [`atom/base16-tomorrow-dark-theme`][base16-tomorrow-dark-theme] | [#17836](https://github.com/atom/atom/issues/17836) |
|
||||
@@ -100,7 +100,6 @@ See [RFC 003](https://github.com/atom/atom/blob/master/docs/rfcs/003-consolidate
|
||||
| **whitespace** | [`atom/whitespace`][whitespace] | |
|
||||
| **wrap-guide** | [`atom/wrap-guide`][wrap-guide] | |
|
||||
|
||||
[about]: https://github.com/atom/about
|
||||
[archive-view]: https://github.com/atom/archive-view
|
||||
[atom-dark-syntax]: https://github.com/atom/atom-dark-syntax
|
||||
[atom-dark-ui]: https://github.com/atom/atom-dark-ui
|
||||
@@ -111,7 +110,6 @@ See [RFC 003](https://github.com/atom/atom/blob/master/docs/rfcs/003-consolidate
|
||||
[autocomplete-html]: https://github.com/atom/autocomplete-html
|
||||
[autocomplete-plus]: https://github.com/atom/autocomplete-plus
|
||||
[autocomplete-snippets]: https://github.com/atom/autocomplete-snippets
|
||||
[autoflow]: https://github.com/atom/autoflow
|
||||
[autosave]: https://github.com/atom/autosave
|
||||
[background-tips]: https://github.com/atom/background-tips
|
||||
[base16-tomorrow-dark-theme]: https://github.com/atom/base16-tomorrow-dark-theme
|
||||
@@ -170,7 +168,6 @@ See [RFC 003](https://github.com/atom/atom/blob/master/docs/rfcs/003-consolidate
|
||||
[markdown-preview]: https://github.com/atom/markdown-preview
|
||||
[metrics]: https://github.com/atom/metrics
|
||||
[notifications]: https://github.com/atom/notifications
|
||||
[one-light-syntax]: https://github.com/atom/one-light-syntax
|
||||
[open-on-github]: https://github.com/atom/open-on-github
|
||||
[package-generator]: https://github.com/atom/package-generator
|
||||
[settings-view]: https://github.com/atom/settings-view
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"version": "1.9.1",
|
||||
"description": "View useful information about your Atom installation.",
|
||||
"keywords": [],
|
||||
"repository": "https://github.com/atom/about",
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"lint": "standard"
|
||||
|
||||
1
packages/autoflow/.coffeelintignore
Normal file
1
packages/autoflow/.coffeelintignore
Normal file
@@ -0,0 +1 @@
|
||||
spec/fixtures
|
||||
1
packages/autoflow/.gitignore
vendored
Normal file
1
packages/autoflow/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
20
packages/autoflow/LICENSE.md
Normal file
20
packages/autoflow/LICENSE.md
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
5
packages/autoflow/README.md
Normal file
5
packages/autoflow/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Autoflow package
|
||||
|
||||
Format the current selection to have lines no longer than 80 characters using `cmd-alt-q` on macOS and `ctrl-shift-q` on Windows and Linux. If nothing is selected, the current paragraph will be reflowed.
|
||||
|
||||
This package uses the config value of `editor.preferredLineLength` when set to determine desired line length.
|
||||
37
packages/autoflow/coffeelint.json
Normal file
37
packages/autoflow/coffeelint.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"max_line_length": {
|
||||
"level": "ignore"
|
||||
},
|
||||
"no_empty_param_list": {
|
||||
"level": "error"
|
||||
},
|
||||
"arrow_spacing": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_interpolation_in_single_quotes": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_debugger": {
|
||||
"level": "error"
|
||||
},
|
||||
"prefer_english_operator": {
|
||||
"level": "error"
|
||||
},
|
||||
"colon_assignment_spacing": {
|
||||
"spacing": {
|
||||
"left": 0,
|
||||
"right": 1
|
||||
},
|
||||
"level": "error"
|
||||
},
|
||||
"braces_spacing": {
|
||||
"spaces": 0,
|
||||
"level": "error"
|
||||
},
|
||||
"spacing_after_comma": {
|
||||
"level": "error"
|
||||
},
|
||||
"no_stand_alone_at": {
|
||||
"level": "error"
|
||||
}
|
||||
}
|
||||
5
packages/autoflow/keymaps/autoflow.cson
Normal file
5
packages/autoflow/keymaps/autoflow.cson
Normal file
@@ -0,0 +1,5 @@
|
||||
'.platform-darwin atom-text-editor':
|
||||
'alt-cmd-q': 'autoflow:reflow-selection'
|
||||
|
||||
'.platform-win32 atom-text-editor, .platform-linux atom-text-editor':
|
||||
'ctrl-shift-q': 'autoflow:reflow-selection'
|
||||
115
packages/autoflow/lib/autoflow.coffee
Normal file
115
packages/autoflow/lib/autoflow.coffee
Normal file
@@ -0,0 +1,115 @@
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
CharacterPattern = ///
|
||||
[
|
||||
^\s
|
||||
]
|
||||
///
|
||||
|
||||
module.exports =
|
||||
activate: ->
|
||||
@commandDisposable = atom.commands.add 'atom-text-editor',
|
||||
'autoflow:reflow-selection': (event) =>
|
||||
@reflowSelection(event.currentTarget.getModel())
|
||||
|
||||
deactivate: ->
|
||||
@commandDisposable?.dispose()
|
||||
@commandDisposable = null
|
||||
|
||||
reflowSelection: (editor) ->
|
||||
range = editor.getSelectedBufferRange()
|
||||
range = editor.getCurrentParagraphBufferRange() if range.isEmpty()
|
||||
return unless range?
|
||||
|
||||
reflowOptions =
|
||||
wrapColumn: @getPreferredLineLength(editor)
|
||||
tabLength: @getTabLength(editor)
|
||||
reflowedText = @reflow(editor.getTextInRange(range), reflowOptions)
|
||||
editor.getBuffer().setTextInRange(range, reflowedText)
|
||||
|
||||
reflow: (text, {wrapColumn, tabLength}) ->
|
||||
paragraphs = []
|
||||
# Convert all \r\n and \r to \n. The text buffer will normalize them later
|
||||
text = text.replace(/\r\n?/g, '\n')
|
||||
|
||||
leadingVerticalSpace = text.match(/^\s*\n/)
|
||||
if leadingVerticalSpace
|
||||
text = text.substr(leadingVerticalSpace.length)
|
||||
else
|
||||
leadingVerticalSpace = ''
|
||||
|
||||
trailingVerticalSpace = text.match(/\n\s*$/)
|
||||
if trailingVerticalSpace
|
||||
text = text.substr(0, text.length - trailingVerticalSpace.length)
|
||||
else
|
||||
trailingVerticalSpace = ''
|
||||
|
||||
paragraphBlocks = text.split(/\n\s*\n/g)
|
||||
if tabLength
|
||||
tabLengthInSpaces = Array(tabLength + 1).join(' ')
|
||||
else
|
||||
tabLengthInSpaces = ''
|
||||
|
||||
for block in paragraphBlocks
|
||||
|
||||
# TODO: this could be more language specific. Use the actual comment char.
|
||||
# Remember that `-` has to be the last character in the character class.
|
||||
linePrefix = block.match(/^\s*(\/\/|\/\*|;;|#'|\|\|\||--|[#%*>-])?\s*/g)[0]
|
||||
linePrefixTabExpanded = linePrefix
|
||||
if tabLengthInSpaces
|
||||
linePrefixTabExpanded = linePrefix.replace(/\t/g, tabLengthInSpaces)
|
||||
blockLines = block.split('\n')
|
||||
|
||||
if linePrefix
|
||||
escapedLinePrefix = _.escapeRegExp(linePrefix)
|
||||
blockLines = blockLines.map (blockLine) ->
|
||||
blockLine.replace(///^#{escapedLinePrefix}///, '')
|
||||
|
||||
blockLines = blockLines.map (blockLine) ->
|
||||
blockLine.replace(/^\s+/, '')
|
||||
|
||||
lines = []
|
||||
currentLine = []
|
||||
currentLineLength = linePrefixTabExpanded.length
|
||||
|
||||
wrappedLinePrefix = linePrefix
|
||||
.replace(/^(\s*)\/\*/, '$1 ')
|
||||
.replace(/^(\s*)-(?!-)/, '$1 ')
|
||||
|
||||
firstLine = true
|
||||
for segment in @segmentText(blockLines.join(' '))
|
||||
if @wrapSegment(segment, currentLineLength, wrapColumn)
|
||||
|
||||
# Independent of line prefix don't mess with it on the first line
|
||||
if firstLine isnt true
|
||||
# Handle C comments
|
||||
if linePrefix.search(/^\s*\/\*/) isnt -1 or linePrefix.search(/^\s*-(?!-)/) isnt -1
|
||||
linePrefix = wrappedLinePrefix
|
||||
lines.push(linePrefix + currentLine.join(''))
|
||||
currentLine = []
|
||||
currentLineLength = linePrefixTabExpanded.length
|
||||
firstLine = false
|
||||
currentLine.push(segment)
|
||||
currentLineLength += segment.length
|
||||
lines.push(linePrefix + currentLine.join(''))
|
||||
|
||||
paragraphs.push(lines.join('\n').replace(/\s+\n/g, '\n'))
|
||||
|
||||
leadingVerticalSpace + paragraphs.join('\n\n') + trailingVerticalSpace
|
||||
|
||||
getTabLength: (editor) ->
|
||||
atom.config.get('editor.tabLength', scope: editor.getRootScopeDescriptor()) ? 2
|
||||
|
||||
getPreferredLineLength: (editor) ->
|
||||
atom.config.get('editor.preferredLineLength', scope: editor.getRootScopeDescriptor())
|
||||
|
||||
wrapSegment: (segment, currentLineLength, wrapColumn) ->
|
||||
CharacterPattern.test(segment) and
|
||||
(currentLineLength + segment.length > wrapColumn) and
|
||||
(currentLineLength > 0 or segment.length < wrapColumn)
|
||||
|
||||
segmentText: (text) ->
|
||||
segments = []
|
||||
re = /[\s]+|[^\s]+/g
|
||||
segments.push(match[0]) while match = re.exec(text)
|
||||
segments
|
||||
11
packages/autoflow/menus/autoflow.cson
Normal file
11
packages/autoflow/menus/autoflow.cson
Normal file
@@ -0,0 +1,11 @@
|
||||
'menu': [
|
||||
{
|
||||
'label': 'Edit'
|
||||
'submenu': [
|
||||
{
|
||||
'label': 'Reflow Selection'
|
||||
'command': 'autoflow:reflow-selection'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
22
packages/autoflow/package.json
Normal file
22
packages/autoflow/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "autoflow",
|
||||
"version": "0.29.4",
|
||||
"main": "./lib/autoflow",
|
||||
"description": "Format the current selection to have lines no longer than 80 characters.\n\nThis packages uses the config value of `editor.preferredLineLength` when set.",
|
||||
"activationCommands": {
|
||||
"atom-text-editor": [
|
||||
"autoflow:reflow-selection"
|
||||
]
|
||||
},
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"atom": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore-plus": "^1.6.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffeelint": "^1.9.7"
|
||||
}
|
||||
}
|
||||
562
packages/autoflow/spec/autoflow-spec.coffee
Normal file
562
packages/autoflow/spec/autoflow-spec.coffee
Normal file
@@ -0,0 +1,562 @@
|
||||
describe "Autoflow package", ->
|
||||
[autoflow, editor, editorElement] = []
|
||||
tabLength = 4
|
||||
|
||||
describe "autoflow:reflow-selection", ->
|
||||
beforeEach ->
|
||||
activationPromise = null
|
||||
|
||||
waitsForPromise ->
|
||||
atom.workspace.open()
|
||||
|
||||
runs ->
|
||||
editor = atom.workspace.getActiveTextEditor()
|
||||
editorElement = atom.views.getView(editor)
|
||||
|
||||
atom.config.set('editor.preferredLineLength', 30)
|
||||
atom.config.set('editor.tabLength', tabLength)
|
||||
|
||||
activationPromise = atom.packages.activatePackage('autoflow')
|
||||
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
waitsForPromise ->
|
||||
activationPromise
|
||||
|
||||
it "uses the preferred line length based on the editor's scope", ->
|
||||
atom.config.set('editor.preferredLineLength', 4, scopeSelector: '.text.plain.null-grammar')
|
||||
editor.setText("foo bar")
|
||||
editor.selectAll()
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
expect(editor.getText()).toBe """
|
||||
foo
|
||||
bar
|
||||
"""
|
||||
|
||||
it "rearranges line breaks in the current selection to ensure lines are shorter than config.editor.preferredLineLength honoring tabLength", ->
|
||||
editor.setText "\t\tThis is the first paragraph and it is longer than the preferred line length so it should be reflowed.\n\n\t\tThis is a short paragraph.\n\n\t\tAnother long paragraph, it should also be reflowed with the use of this single command."
|
||||
|
||||
editor.selectAll()
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
exedOut = editor.getText().replace(/\t/g, Array(tabLength+1).join 'X')
|
||||
expect(exedOut).toBe "XXXXXXXXThis is the first\nXXXXXXXXparagraph and it is\nXXXXXXXXlonger than the\nXXXXXXXXpreferred line length\nXXXXXXXXso it should be\nXXXXXXXXreflowed.\n\nXXXXXXXXThis is a short\nXXXXXXXXparagraph.\n\nXXXXXXXXAnother long\nXXXXXXXXparagraph, it should\nXXXXXXXXalso be reflowed with\nXXXXXXXXthe use of this single\nXXXXXXXXcommand."
|
||||
|
||||
it "rearranges line breaks in the current selection to ensure lines are shorter than config.editor.preferredLineLength", ->
|
||||
editor.setText """
|
||||
This is the first paragraph and it is longer than the preferred line length so it should be reflowed.
|
||||
|
||||
This is a short paragraph.
|
||||
|
||||
Another long paragraph, it should also be reflowed with the use of this single command.
|
||||
"""
|
||||
|
||||
editor.selectAll()
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
expect(editor.getText()).toBe """
|
||||
This is the first paragraph
|
||||
and it is longer than the
|
||||
preferred line length so it
|
||||
should be reflowed.
|
||||
|
||||
This is a short paragraph.
|
||||
|
||||
Another long paragraph, it
|
||||
should also be reflowed with
|
||||
the use of this single
|
||||
command.
|
||||
"""
|
||||
|
||||
it "is not confused when the selection boundary is between paragraphs", ->
|
||||
editor.setText """
|
||||
v--- SELECTION STARTS AT THE BEGINNING OF THE NEXT LINE (pos 1,0)
|
||||
|
||||
The preceding newline should not be considered part of this paragraph.
|
||||
|
||||
The newline at the end of this paragraph should be preserved and not
|
||||
converted into a space.
|
||||
|
||||
^--- SELECTION ENDS AT THE BEGINNING OF THE PREVIOUS LINE (pos 6,0)
|
||||
"""
|
||||
|
||||
editor.setCursorBufferPosition([1, 0])
|
||||
editor.selectToBufferPosition([6, 0])
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
expect(editor.getText()).toBe """
|
||||
v--- SELECTION STARTS AT THE BEGINNING OF THE NEXT LINE (pos 1,0)
|
||||
|
||||
The preceding newline should
|
||||
not be considered part of this
|
||||
paragraph.
|
||||
|
||||
The newline at the end of this
|
||||
paragraph should be preserved
|
||||
and not converted into a
|
||||
space.
|
||||
|
||||
^--- SELECTION ENDS AT THE BEGINNING OF THE PREVIOUS LINE (pos 6,0)
|
||||
"""
|
||||
|
||||
it "reflows the current paragraph if nothing is selected", ->
|
||||
editor.setText """
|
||||
This is a preceding paragraph, which shouldn't be modified by a reflow of the following paragraph.
|
||||
|
||||
The quick brown fox jumps over the lazy
|
||||
dog. The preceding sentence contains every letter
|
||||
in the entire English alphabet, which has absolutely no relevance
|
||||
to this test.
|
||||
|
||||
This is a following paragraph, which shouldn't be modified by a reflow of the preciding paragraph.
|
||||
|
||||
"""
|
||||
|
||||
editor.setCursorBufferPosition([3, 5])
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
expect(editor.getText()).toBe """
|
||||
This is a preceding paragraph, which shouldn't be modified by a reflow of the following paragraph.
|
||||
|
||||
The quick brown fox jumps over
|
||||
the lazy dog. The preceding
|
||||
sentence contains every letter
|
||||
in the entire English
|
||||
alphabet, which has absolutely
|
||||
no relevance to this test.
|
||||
|
||||
This is a following paragraph, which shouldn't be modified by a reflow of the preciding paragraph.
|
||||
|
||||
"""
|
||||
|
||||
it "allows for single words that exceed the preferred wrap column length", ->
|
||||
editor.setText("this-is-a-super-long-word-that-shouldn't-break-autoflow and these are some smaller words")
|
||||
|
||||
editor.selectAll()
|
||||
atom.commands.dispatch editorElement, 'autoflow:reflow-selection'
|
||||
|
||||
expect(editor.getText()).toBe """
|
||||
this-is-a-super-long-word-that-shouldn't-break-autoflow
|
||||
and these are some smaller
|
||||
words
|
||||
"""
|
||||
|
||||
describe "reflowing text", ->
|
||||
beforeEach ->
|
||||
autoflow = require("../lib/autoflow")
|
||||
|
||||
it 'respects current paragraphs', ->
|
||||
text = '''
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh id magna ullamcorper sagittis. Maecenas
|
||||
et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
Phasellus gravida
|
||||
nibh id magna ullamcorper
|
||||
tincidunt adipiscing lacinia a dui. Etiam quis erat dolor.
|
||||
rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis fermentum.
|
||||
'''
|
||||
|
||||
res = '''
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh
|
||||
id magna ullamcorper sagittis. Maecenas et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh
|
||||
id magna ullamcorper tincidunt adipiscing lacinia a dui. Etiam quis erat dolor.
|
||||
rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis fermentum.
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'respects indentation', ->
|
||||
text = '''
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh id magna ullamcorper sagittis. Maecenas
|
||||
et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
Phasellus gravida
|
||||
nibh id magna ullamcorper
|
||||
tincidunt adipiscing lacinia a dui. Etiam quis erat dolor.
|
||||
rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis fermentum
|
||||
'''
|
||||
|
||||
res = '''
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh
|
||||
id magna ullamcorper sagittis. Maecenas et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida
|
||||
nibh id magna ullamcorper tincidunt adipiscing lacinia a dui. Etiam quis
|
||||
erat dolor. rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis
|
||||
fermentum
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'respects prefixed text (comments!)', ->
|
||||
text = '''
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh id magna ullamcorper sagittis. Maecenas
|
||||
et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
# Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
# Phasellus gravida
|
||||
# nibh id magna ullamcorper
|
||||
# tincidunt adipiscing lacinia a dui. Etiam quis erat dolor.
|
||||
# rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis fermentum
|
||||
'''
|
||||
|
||||
res = '''
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida nibh
|
||||
id magna ullamcorper sagittis. Maecenas et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida
|
||||
# nibh id magna ullamcorper tincidunt adipiscing lacinia a dui. Etiam quis
|
||||
# erat dolor. rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis
|
||||
# fermentum
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'respects multiple prefixes (js/c comments)', ->
|
||||
text = '''
|
||||
// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida
|
||||
et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
'''
|
||||
|
||||
res = '''
|
||||
// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida et
|
||||
// enim eu orci tincidunt adipiscing aliquam ligula.
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly handles * prefix', ->
|
||||
text = '''
|
||||
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida
|
||||
et enim eu orci tincidunt adipiscing
|
||||
aliquam ligula.
|
||||
|
||||
* soidjfiojsoidj foi
|
||||
'''
|
||||
|
||||
res = '''
|
||||
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida et
|
||||
* enim eu orci tincidunt adipiscing aliquam ligula.
|
||||
|
||||
* soidjfiojsoidj foi
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it "does not throw invalid regular expression errors (regression)", ->
|
||||
text = '''
|
||||
*** Lorem ipsum dolor sit amet
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual text
|
||||
|
||||
it 'handles different initial indentation', ->
|
||||
text = '''
|
||||
Magna ea magna fugiat nisi minim in id duis. Culpa sit sint consequat quis elit magna pariatur incididunt
|
||||
proident laborum deserunt est aliqua reprehenderit. Occaecat et ex non do Lorem irure adipisicing mollit excepteur
|
||||
eu ullamco consectetur. Ex ex Lorem duis labore quis ad exercitation elit dolor non adipisicing. Pariatur commodo ullamco
|
||||
culpa dolor sunt enim. Ullamco dolore do ea nulla ut commodo minim consequat cillum ad velit quis.
|
||||
'''
|
||||
|
||||
res = '''
|
||||
Magna ea magna fugiat nisi minim in id duis. Culpa sit sint consequat quis elit
|
||||
magna pariatur incididunt proident laborum deserunt est aliqua reprehenderit.
|
||||
Occaecat et ex non do Lorem irure adipisicing mollit excepteur eu ullamco
|
||||
consectetur. Ex ex Lorem duis labore quis ad exercitation elit dolor non
|
||||
adipisicing. Pariatur commodo ullamco culpa dolor sunt enim. Ullamco dolore do
|
||||
ea nulla ut commodo minim consequat cillum ad velit quis.
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly handles CRLF', ->
|
||||
text = "This is the first line and it is longer than the preferred line length so it should be reflowed.\r\nThis is a short line which should\r\nbe reflowed with the following line.\rAnother long line, it should also be reflowed with everything above it when it is all reflowed."
|
||||
|
||||
res =
|
||||
'''
|
||||
This is the first line and it is longer than the preferred line length so it
|
||||
should be reflowed. This is a short line which should be reflowed with the
|
||||
following line. Another long line, it should also be reflowed with everything
|
||||
above it when it is all reflowed.
|
||||
'''
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'handles cyrillic text', ->
|
||||
text = '''
|
||||
В начале июля, в чрезвычайно жаркое время, под вечер, один молодой человек вышел из своей каморки, которую нанимал от жильцов в С-м переулке, на улицу и медленно, как бы в нерешимости, отправился к К-ну мосту.
|
||||
'''
|
||||
|
||||
res = '''
|
||||
В начале июля, в чрезвычайно жаркое время, под вечер, один молодой человек вышел
|
||||
из своей каморки, которую нанимал от жильцов в С-м переулке, на улицу и
|
||||
медленно, как бы в нерешимости, отправился к К-ну мосту.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'handles `yo` character properly', ->
|
||||
# Because there're known problems with this character in major regex engines
|
||||
text = 'Ё Ё Ё'
|
||||
|
||||
res = '''
|
||||
Ё
|
||||
Ё
|
||||
Ё
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 2)).toEqual res
|
||||
|
||||
it 'properly reflows // comments ', ->
|
||||
text =
|
||||
'''
|
||||
// Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
// Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
// sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
// fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest
|
||||
// quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro
|
||||
// actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia
|
||||
// sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher
|
||||
// direct trade, tacos pickled fanny pack literally meh pinterest slow-carb.
|
||||
// Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly reflows /* comments ', ->
|
||||
text =
|
||||
'''
|
||||
/* Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas. */
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
/* Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest
|
||||
quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro
|
||||
actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia
|
||||
sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher
|
||||
direct trade, tacos pickled fanny pack literally meh pinterest slow-carb.
|
||||
Meditation microdosing distillery 8-bit humblebrag migas. */
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly reflows pound comments ', ->
|
||||
text =
|
||||
'''
|
||||
# Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
# Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha
|
||||
# banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
# fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa
|
||||
# leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually
|
||||
# aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial
|
||||
# letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade,
|
||||
# tacos pickled fanny pack literally meh pinterest slow-carb. Meditation
|
||||
# microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly reflows - list items ', ->
|
||||
text =
|
||||
'''
|
||||
- Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
- Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha
|
||||
banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa
|
||||
leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually
|
||||
aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial
|
||||
letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade,
|
||||
tacos pickled fanny pack literally meh pinterest slow-carb. Meditation
|
||||
microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly reflows % comments ', ->
|
||||
text =
|
||||
'''
|
||||
% Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
% Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha
|
||||
% banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
% fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa
|
||||
% leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually
|
||||
% aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial
|
||||
% letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade,
|
||||
% tacos pickled fanny pack literally meh pinterest slow-carb. Meditation
|
||||
% microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it "properly reflows roxygen comments ", ->
|
||||
text =
|
||||
'''
|
||||
#' Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
#' Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
#' sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
#' fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest
|
||||
#' quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro
|
||||
#' actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia
|
||||
#' sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher
|
||||
#' direct trade, tacos pickled fanny pack literally meh pinterest slow-carb.
|
||||
#' Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it "properly reflows -- comments ", ->
|
||||
text =
|
||||
'''
|
||||
-- Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
-- Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
-- sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
-- fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest
|
||||
-- quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro
|
||||
-- actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia
|
||||
-- sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher
|
||||
-- direct trade, tacos pickled fanny pack literally meh pinterest slow-carb.
|
||||
-- Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it "properly reflows ||| comments ", ->
|
||||
text =
|
||||
'''
|
||||
||| Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
||| Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
||| sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
||| fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest
|
||||
||| quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro
|
||||
||| actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia
|
||||
||| sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher
|
||||
||| direct trade, tacos pickled fanny pack literally meh pinterest slow-carb.
|
||||
||| Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly reflows ;; comments ', ->
|
||||
text =
|
||||
'''
|
||||
;; Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
;; Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
;; sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
;; fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest
|
||||
;; quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro
|
||||
;; actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia
|
||||
;; sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher
|
||||
;; direct trade, tacos pickled fanny pack literally meh pinterest slow-carb.
|
||||
;; Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'does not treat lines starting with a single semicolon as ;; comments', ->
|
||||
text =
|
||||
'''
|
||||
;! Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
;! Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard
|
||||
sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa
|
||||
leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually
|
||||
aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial
|
||||
letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade,
|
||||
tacos pickled fanny pack literally meh pinterest slow-carb. Meditation
|
||||
microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it 'properly reflows > ascii email inclusions ', ->
|
||||
text =
|
||||
'''
|
||||
> Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha banh mi, cold-pressed retro whatever ethical man braid asymmetrical fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade, tacos pickled fanny pack literally meh pinterest slow-carb. Meditation microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
> Beard pinterest actually brunch brooklyn jean shorts YOLO. Knausgaard sriracha
|
||||
> banh mi, cold-pressed retro whatever ethical man braid asymmetrical
|
||||
> fingerstache narwhal. Intelligentsia wolf photo booth, tumblr pinterest quinoa
|
||||
> leggings four loko poutine. DIY tattooed drinking vinegar, wolf retro actually
|
||||
> aesthetic austin keffiyeh marfa beard. Marfa trust fund salvia sartorial
|
||||
> letterpress, keffiyeh plaid butcher. Swag try-hard dreamcatcher direct trade,
|
||||
> tacos pickled fanny pack literally meh pinterest slow-carb. Meditation
|
||||
> microdosing distillery 8-bit humblebrag migas.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(text, wrapColumn: 80)).toEqual res
|
||||
|
||||
it "doesn't allow special characters to surpass wrapColumn", ->
|
||||
test =
|
||||
'''
|
||||
Imagine that I'm writing some LaTeX code. I start a comment, but change my mind. %
|
||||
|
||||
Now I'm just kind of trucking along, doing some math and stuff. For instance, $3 + 4 = 7$. But maybe I'm getting really crazy and I use subtraction. It's kind of an obscure technique, but often it goes a bit like this: let $x = 2 + 2$, so $x - 1 = 3$ (quick maths).
|
||||
|
||||
That's OK I guess, but now look at this cool thing called set theory: $\\{n + 42 : n \\in \\mathbb{N}\\}$. Wow. Neat. But we all know why we're really here. If you peer deep down into your heart, and you stare into the depths of yourself: is $P = NP$? Beware, though; many have tried and failed to answer this question. It is by no means for the faint of heart.
|
||||
'''
|
||||
|
||||
res =
|
||||
'''
|
||||
Imagine that I'm writing some LaTeX code. I start a comment, but change my mind.
|
||||
%
|
||||
|
||||
Now I'm just kind of trucking along, doing some math and stuff. For instance, $3
|
||||
+ 4 = 7$. But maybe I'm getting really crazy and I use subtraction. It's kind of
|
||||
an obscure technique, but often it goes a bit like this: let $x = 2 + 2$, so $x
|
||||
- 1 = 3$ (quick maths).
|
||||
|
||||
That's OK I guess, but now look at this cool thing called set theory: $\\{n + 42
|
||||
: n \\in \\mathbb{N}\\}$. Wow. Neat. But we all know why we're really here. If you
|
||||
peer deep down into your heart, and you stare into the depths of yourself: is $P
|
||||
= NP$? Beware, though; many have tried and failed to answer this question. It is
|
||||
by no means for the faint of heart.
|
||||
'''
|
||||
|
||||
expect(autoflow.reflow(test, wrapColumn: 80)).toEqual res
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "1.3.9",
|
||||
"main": "./lib/main",
|
||||
"description": "Marks lines in the editor gutter that have been added, edited, or deleted since the last commit.",
|
||||
"repository": "https://github.com/atom/git-diff",
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"atom": "*"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"blue",
|
||||
"syntax"
|
||||
],
|
||||
"repository": "https://github.com/atom/one-dark-syntax",
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"atom": ">0.50.0"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"ui"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/atom/one-dark-ui",
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"main": "lib/main",
|
||||
"engines": {
|
||||
"atom": ">0.40.0"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"light",
|
||||
"syntax"
|
||||
],
|
||||
"repository": "https://github.com/atom/one-light-syntax",
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"atom": ">0.40.0"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"ui"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/atom/one-light-ui",
|
||||
"repository": "https://github.com/atom/atom",
|
||||
"main": "lib/main",
|
||||
"engines": {
|
||||
"atom": ">0.40.0"
|
||||
|
||||
Reference in New Issue
Block a user