# Copyright (c) 2008-2023 Minero Aoki, Kenshi Muto # 2002-2007 Minero Aoki # # This program is free software. # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # require 'review/builder' require 'review/htmlutils' require 'review/textutils' require 'nkf' module ReVIEW class IDGXMLBuilder < Builder include TextUtils include HTMLUtils %i[ttbold hint maru keytop labelref ref strong em].each do |e| Compiler.definline(e) end Compiler.defsingle(:dtp, 1) Compiler.defblock(:insn, 0..1) Compiler.defblock(:planning, 0..1) Compiler.defblock(:best, 0..1) Compiler.defblock(:security, 0..1) Compiler.defblock(:point, 0..1) Compiler.defblock(:shoot, 0..1) Compiler.defblock(:reference, 0) Compiler.defblock(:term, 0) Compiler.defblock(:link, 0..1) Compiler.defblock(:practice, 0) Compiler.defblock(:expert, 0) Compiler.defblock(:rawblock, 0) def pre_paragraph '

' end def post_paragraph '

' end def extname '.xml' end def builder_init_file super @warns = [] @errors = [] @section = 0 @subsection = 0 @subsubsection = 0 @subsubsubsection = 0 @sec_counter = SecCounter.new(5, @chapter) @column = 0 @noindent = nil @ol_num = nil @first_line_num = nil @rootelement = 'doc' @tsize = nil @texblockequation = 0 @texinlineequation = 0 print %Q(\n) print %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">) @secttags = @book.config['structuredxml'] end private :builder_init_file def puts(arg) if @book.config['nolf'].present? print arg else super end end def result check_printendnotes s = '' if @secttags s += '' if @subsubsubsection > 0 s += '' if @subsubsection > 0 s += '' if @subsection > 0 s += '' if @section > 0 s += '' end solve_nest(@output.string) + s + "\n" end def solve_nest(s) check_nest s.gsub("\x01→dl←\x01", ''). gsub("\x01→/dl←\x01", "←END\x01"). gsub("\x01→ul←\x01", ''). gsub("\x01→/ul←\x01", "←END\x01"). gsub("\x01→ol←\x01", ''). gsub("\x01→/ol←\x01", "←END\x01"). gsub("←END\x01
", ''). gsub("←END\x01