Last active
December 1, 2019 03:33
-
-
Save kmuto/974e9ff0f1096111b760f433fe37fd4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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