Skip to content

Commit

Permalink
Ignore blank lines in checking multi-line indent.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwo committed Mar 2, 2021
1 parent 56c8b8a commit 9da6ddf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/dbml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ def self.block type, name_parser, content_parser, &block
# MULTI_LINE_STRING ignores indentation on the first line: "''' long\n string'''" => "long\n string"
# MULTI_LINE_STRING allows apostrophes: "'''it's a string with '' bunny ears'''" => "it's a string with '' bunny ears"
# MULTI_LINE_STRING allows blanks: "''''''" => ""
MULTI_LINE_STRING = seq("'''".r, /([^']|'[^']|''[^'])*/m.r, "'''".r)[1].map do |string|
# MULTI_LINE_STRING allows blank lines to have no indent: "''' my string\n\n it's really great'''" => "my string\nit's really great"
# MULTI_LINE_STRING allows blank first lines: "'''\n start of\n my writing'''" => "start of\nmy writing"
MULTI_LINE_STRING = seq(/'''\n?/.r, /([^']|'[^']|''[^'])*/m.r, /\n?'''/.r)[1].map do |string|
indent = string.match(/^\s*/m)[0].size
string.lines.map do |line|
raise "Indentation does not match" unless line =~ /\s{#{indent}}/
raise "Indentation does not match in #{line.inspect}" unless line =~ /\s{#{indent}}/ or line =~ /^\n$/
line[indent..]
end.join
end
Expand Down

0 comments on commit 9da6ddf

Please sign in to comment.