Handle * prefixes properly

This commit is contained in:
Ben Ogle
2013-07-23 15:58:42 -07:00
parent e76fe439ba
commit 11a1a27dbd
2 changed files with 18 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ module.exports =
# 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
blockLines = (blockLine.replace(new RegExp('^' + linePrefix.replace('*', '\\*')), '') for blockLine in blockLines) if linePrefix
lines = []
currentLine = []

View File

@@ -147,3 +147,20 @@ describe "Autoflow package", ->
// 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