Permalink
Browse files

Fix and improve literal mode.

  * Require a blank line as delimiter between text and code.
  * Don't ignore indentation with mixed whitespace.
  * Handle blank lines depending on preceding lines.
    (Addresses changes in #190.)
  * Bonus: Remove unused variable (leftover from #190).
  • Loading branch information...
1 parent b506b6d commit b5eb357f95c6ebf1e70e44863862adcf41edcd85 @marchaefner marchaefner committed Apr 8, 2013
Showing with 9 additions and 9 deletions.
  1. +3 −4 docco.js
  2. +6 −5 docco.litcoffee
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -126,24 +126,25 @@ invert the prose and code relationship on a per-line basis, and then continue as
normal below.
if lang.literate
+ isText = maybeCode = yes
for line, i in lines
- lines[i] = if /^\s*$/.test line
- ''
- else if match = (/^([ ]{4}|\t)/).exec line
+ lines[i] = if maybeCode and match = /^([ ]{4}|[ ]{0,3}\t)/.exec line
+ isText = no
line[match[0].length..]
+ else if maybeCode = /^\s*$/.test line
+ if isText then lang.symbol else ''
else
+ isText = yes
lang.symbol + ' ' + line
for line in lines
if line.match(lang.commentMatcher) and not line.match(lang.commentFilter)
save() if hasCode
docsText += (line = line.replace(lang.commentMatcher, '')) + '\n'
save() if /^(---+|===+)$/.test line
- prev = 'text'
else
hasCode = yes
codeText += line + '\n'
- prev = 'code'
save()
sections

0 comments on commit b5eb357

Please sign in to comment.