Skip to content

Commit

Permalink
Handle 0 indentation
Browse files Browse the repository at this point in the history
Fixes dmnd#20.
  • Loading branch information
lydell committed Sep 6, 2018
1 parent cbd9b90 commit c86061e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dedent.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export default function dedent(
// now strip indentation
const lines = result.split("\n");
let mindent: number | null = null;
lines.forEach(l => {
let m = l.match(/^(\s+)\S+/);
if (m) {
let indent = m[1].length;
if (!mindent) {
lines.forEach((l, i) => {
let m = l.match(/^(\s*)\S+/);
let indent = m == null ? null : m[1].length;
if (indent != null && !(i === 0 && indent === 0)) {
if (mindent == null) {
// this is the first indented line
mindent = indent;
} else {
Expand Down

0 comments on commit c86061e

Please sign in to comment.