mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 18:07:25 +00:00
28 lines
394 B
Ruby
28 lines
394 B
Ruby
|
require 'nokogiri'
|
||
|
|
||
|
module DText
|
||
|
def parse(str)
|
||
|
# split str into lines (separated by single new line)
|
||
|
# prepare state stack
|
||
|
# start from empty state
|
||
|
|
||
|
state = []
|
||
|
|
||
|
# Normalize newlines
|
||
|
str.gsub(/(\r?\n){3,}/m, "\n\n")
|
||
|
|
||
|
data = str.split("\n")
|
||
|
|
||
|
data.each do |d|
|
||
|
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
def parseline( )
|
||
|
|
||
|
str.gsub(/^(h[1-6])\.\s+(.+)\n*/m, '<\1>\2</\1>')
|
||
|
end
|
||
|
|
||
|
end
|