mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
respects comment chars
This commit is contained in:
parent
778e3bbd67
commit
f234b8fa27
@ -16,7 +16,8 @@ module.exports =
|
||||
|
||||
for block in paragraphBlocks
|
||||
|
||||
linePrefix = block.match(/^\s*/g)[0]
|
||||
# TODO: this could be more language specific. Use the actual comment char.
|
||||
linePrefix = block.match(/^\s*[\/#*-]*\s*/g)[0]
|
||||
blockLines = block.split('\n')
|
||||
blockLines = (blockLine.replace(new RegExp('^'+linePrefix), '') for blockLine in blockLines) if linePrefix
|
||||
|
||||
|
@ -95,7 +95,7 @@ describe "Autoflow package", ->
|
||||
Phasellus gravida
|
||||
nibh id magna ullamcorper
|
||||
tincidunt adipiscing lacinia a dui. Etiam quis erat dolor.
|
||||
rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis fermentum
|
||||
rutrum nisl fermentum rhoncus. Duis blandit ligula facilisis fermentum
|
||||
'''
|
||||
|
||||
res = '''
|
||||
@ -105,7 +105,45 @@ describe "Autoflow package", ->
|
||||
|
||||
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
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user