Skip to content

Commit

Permalink
Change slides parsing to improve metadata detection
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Nov 1, 2022
1 parent 7c07eef commit b79f5a1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/slideck/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Parser
# @return [Regexp]
#
# @api private
METADATA_PATTERN = /^[^:]+:[^:]+$/.freeze
METADATA_PATTERN = /^\s*:?[^:]+:[^:]+$/.freeze
private_constant :METADATA_PATTERN

# The pattern to detect slide separator
Expand Down
20 changes: 20 additions & 0 deletions spec/unit/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@
})
end

it "parses only indented metadata with symbol keys" do
content = unindent(<<-EOS)
:align: center
:footer: footer content
:pager: "page %<page>d of %<total>d"
EOS
parser = described_class.new(StringScanner, metadata_parser)

deck = parser.parse(content)

expect(deck).to eq({
metadata: {
align: "center",
footer: "footer content",
pager: "page %<page>d of %<total>d"
},
slides: []
})
end

it "parses slides with content and metadata" do
content = unindent(<<-EOS)
align: center
Expand Down

0 comments on commit b79f5a1

Please sign in to comment.