Skip to content

Commit

Permalink
Fix and improve literal mode.
Browse files Browse the repository at this point in the history
  * 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 jashkenas#190.)
  * Bonus: Remove unused variable (leftover from jashkenas#190).
  • Loading branch information
Marc Häfner committed Apr 8, 2013
1 parent b506b6d commit b5eb357
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions docco.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions docco.litcoffee
Expand Up @@ -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
Expand Down

0 comments on commit b5eb357

Please sign in to comment.