Sha256: 732dc744920e9fa0866905e7076fed998b29d6e1ce6e30eae3a89e86414832c0
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
# -*- coding: utf-8 -*- #分析meta值 # http://pythonhosted.org/Markdown/extensions/meta_data.html class Meta def initialize end #分析meta的部分 def analysis_meta(original) return nil if not original result = Hash.new list = original.split(/[\r\n?]/) # 提取meta值 list.each{ |line| next if line == '' next if (/^(\w+):(.+)/i =~ line) == nil key = $1.lstrip.rstrip value = $2.lstrip.rstrip result[key] = value } result end #分析内容 def analysis(original) result = Hash.new pattern = /(\s+)?<!\-\-(.+?)\-\->(.+)?/m matches = pattern.match(original) #如果没有匹配到, 则body就是完整的original if matches == nil result['body'] = original return result end #获取body内容 result['body'] = $3 result['meta'] = self.analysis_meta $2 result end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
m2m-0.2.9 | lib/meta.rb |
m2m-0.2.8 | lib/meta.rb |
m2m-0.2.7 | lib/meta.rb |