diff --git a/lib/jekyll-spaceship/processors/table-processor.rb b/lib/jekyll-spaceship/processors/table-processor.rb index 284882d..8a0b18f 100644 --- a/lib/jekyll-spaceship/processors/table-processor.rb +++ b/lib/jekyll-spaceship/processors/table-processor.rb @@ -5,6 +5,9 @@ require "nokogiri" module Jekyll::Spaceship class TableProcessor < Processor + ATTR_LIST_PATTERN = /((?(list) do + list.scan(/(\S+)=("|')(.*?)\2|(\S+)/) do |attr| + key = attr[0] + val = attr[2] + single = attr[3] + if !key.nil? + val = (cell.get_attribute(key) || '') + val + cell.set_attribute(key, val) + elsif !single.nil? + if single.start_with? '#' + key = 'id' + val = single[1..-1] + elsif single.start_with? '.' + key = 'class' + val = cell.get_attribute(key) || '' + val += (val.size.zero? ? '' : ' ') + single[1..-1] + elsif ATTR_LIST_REFS.has_key? single + ial_handler.call ATTR_LIST_REFS[single] + end + unless key.nil? + cell.set_attribute(key, val) + end + end + end + end + # handle attribute list + content.scan(ATTR_LIST_PATTERN) do |result| + ref = result[1] + list = result[2] + # handle inline attribute list + ial_handler.call list if ref.nil? + # remove attr_list + content = content.sub(result[0], '') + end + cell.inner_html = content + end + def handle_format(data) cell = data.cell cvter = self.converter('markdown')