Skip to content

Instantly share code, notes, and snippets.

@kmuto
Last active December 1, 2019 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmuto/974e9ff0f1096111b760f433fe37fd4d to your computer and use it in GitHub Desktop.
Save kmuto/974e9ff0f1096111b760f433fe37fd4d to your computer and use it in GitHub Desktop.
def convert(content)
config = ReVIEW::Configure.values
config['builder'] = 'html'
config['secnolevel'] = 0 # 見出し採番しないとして
ReVIEW::I18n.setup(config['language'])
builder = ReVIEW::HTMLBuilder.new
book = ReVIEW::Book::Base.new('.')
book.config = config
compiler = ReVIEW::Compiler.new(builder)
chap = ReVIEW::Book::Chapter.new(book, '20191201', '-', nil, nil)
chap.content = content # 書き出したのをFile.readでもいいとは思うけど
location = ReVIEW::Location.new(nil, nil)
builder.bind(compiler, chap, location)
compiler.compile(chap)
s = builder.result
s = s.gsub('<span class="secno">chapterchapter_postfix</span>', '')
s = s.gsub(/<span class="secno">\d+\.\d+chapter_postfix<\/span>/, '')
s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment