From a4bbe4db2bedd03a2f675731614833b62df5e118 Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 21 May 2010 14:19:35 +0000 Subject: Fixed a bug in the YAML scanner (see #231). --- Changes.textile | 6 ++++++ lib/coderay/scanners/yaml.rb | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Changes.textile b/Changes.textile index 35f9d3d..ad1bd59 100644 --- a/Changes.textile +++ b/Changes.textile @@ -183,6 +183,12 @@ h3. @Scanners::SQL@ See "#221":http://redmine.rubychan.de/issues/221. * *FIXED*: Closes open string groups. +h3. @Scanners::YAML@ + +* *FIXED*: Allow spaces before colon in mappings. + + See "#231":http://redmine.rubychan.de/issues/231. + h3. *NEW*: @Styles::Alpha@ A style that uses transparent HSLA colors as defined in CSS 3. diff --git a/lib/coderay/scanners/yaml.rb b/lib/coderay/scanners/yaml.rb index 3c3928f..514838d 100644 --- a/lib/coderay/scanners/yaml.rb +++ b/lib/coderay/scanners/yaml.rb @@ -75,20 +75,18 @@ module Scanners when match = scan(/[,{}\[\]]/) encoder.text_token match, :operator next - when state == :initial && match = scan(/[\w.() ]*\S(?=: |:$)/) + when state == :initial && match = scan(/[\w.() ]*\S(?= *:(?: |$))/) encoder.text_token match, :key key_indent = column(pos - match.size - 1) - # encoder.text_token key_indent.inspect, :debug state = :colon next - when match = scan(/(?:"[^"\n]*"|'[^'\n]*')(?=: |:$)/) + when match = scan(/(?:"[^"\n]*"|'[^'\n]*')(?= *:(?: |$))/) encoder.begin_group :key encoder.text_token match[0,1], :delimiter encoder.text_token match[1..-2], :content encoder.text_token match[-1,1], :delimiter encoder.end_group :key key_indent = column(pos - match.size - 1) - # encoder.text_token key_indent.inspect, :debug state = :colon next when match = scan(/(![\w\/]+)(:([\w:]+))?/) -- cgit v1.2.1