sisu 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/sisu +367 -0
- data/bin/sisugem +367 -0
- data/data/sisu/image/arrow_next_red.png +0 -0
- data/data/sisu/image/arrow_prev_red.png +0 -0
- data/data/sisu/image/arrow_up_red.png +0 -0
- data/data/sisu/image/b_bluebell.png +0 -0
- data/data/sisu/image/b_doc.png +0 -0
- data/data/sisu/image/b_epub.png +0 -0
- data/data/sisu/image/b_home.png +0 -0
- data/data/sisu/image/b_info.png +0 -0
- data/data/sisu/image/b_odf.png +0 -0
- data/data/sisu/image/b_pdf.png +0 -0
- data/data/sisu/image/b_search.png +0 -0
- data/data/sisu/image/b_toc.png +0 -0
- data/data/sisu/image/bullet_08.png +0 -0
- data/data/sisu/image/bullet_09.png +0 -0
- data/data/sisu/image/bullet_10.png +0 -0
- data/data/sisu/image/bullet_11.png +0 -0
- data/data/sisu/image/bullet_12.png +0 -0
- data/data/sisu/image/bullet_doc.png +0 -0
- data/data/sisu/image/bullet_red.png +0 -0
- data/data/sisu/image/dot_clear.png +0 -0
- data/data/sisu/image/dot_white.png +0 -0
- data/data/sisu/image/gplv3.png +0 -0
- data/data/sisu/image/gplv3_free_software.png +0 -0
- data/data/sisu/image/next.png +0 -0
- data/data/sisu/image/previous.png +0 -0
- data/data/sisu/image/rb7.ico +0 -0
- data/data/sisu/image/sisu.png +0 -0
- data/data/sisu/image/toctoc.png +0 -0
- data/data/sisu/version.yml +5 -0
- data/lib/sisu.rb +94 -0
- data/lib/sisu/air.rb +80 -0
- data/lib/sisu/ao.rb +590 -0
- data/lib/sisu/ao_character_check.rb +102 -0
- data/lib/sisu/ao_composite.rb +286 -0
- data/lib/sisu/ao_doc_objects.rb +565 -0
- data/lib/sisu/ao_doc_str.rb +2269 -0
- data/lib/sisu/ao_endnotes.rb +136 -0
- data/lib/sisu/ao_expand_insertions.rb +514 -0
- data/lib/sisu/ao_hash_digest.rb +174 -0
- data/lib/sisu/ao_idx.rb +422 -0
- data/lib/sisu/ao_images.rb +187 -0
- data/lib/sisu/ao_metadata.rb +86 -0
- data/lib/sisu/ao_misc_arrange.rb +207 -0
- data/lib/sisu/ao_numbering.rb +720 -0
- data/lib/sisu/ao_persist.rb +194 -0
- data/lib/sisu/ao_references.rb +502 -0
- data/lib/sisu/ao_syntax.rb +640 -0
- data/lib/sisu/cgi.rb +84 -0
- data/lib/sisu/cgi_pgsql.rb +270 -0
- data/lib/sisu/cgi_sql_common.rb +986 -0
- data/lib/sisu/cgi_sqlite.rb +244 -0
- data/lib/sisu/conf.rb +287 -0
- data/lib/sisu/constants.rb +388 -0
- data/lib/sisu/css.rb +3484 -0
- data/lib/sisu/db_columns.rb +1997 -0
- data/lib/sisu/db_create.rb +689 -0
- data/lib/sisu/db_dbi.rb +90 -0
- data/lib/sisu/db_drop.rb +207 -0
- data/lib/sisu/db_import.rb +877 -0
- data/lib/sisu/db_indexes.rb +146 -0
- data/lib/sisu/db_load_tuple.rb +323 -0
- data/lib/sisu/db_remove.rb +182 -0
- data/lib/sisu/db_select.rb +230 -0
- data/lib/sisu/db_sqltxt.rb +173 -0
- data/lib/sisu/db_tests.rb +114 -0
- data/lib/sisu/dbi.rb +166 -0
- data/lib/sisu/dbi_discrete.rb +206 -0
- data/lib/sisu/digests.rb +306 -0
- data/lib/sisu/dp.rb +1606 -0
- data/lib/sisu/dp_identify_markup.rb +161 -0
- data/lib/sisu/dp_make.rb +668 -0
- data/lib/sisu/embedded.rb +149 -0
- data/lib/sisu/errors.rb +84 -0
- data/lib/sisu/generic_parts.rb +131 -0
- data/lib/sisu/git.rb +277 -0
- data/lib/sisu/html.rb +775 -0
- data/lib/sisu/html_concordance.rb +391 -0
- data/lib/sisu/html_format.rb +1348 -0
- data/lib/sisu/html_harvest.rb +109 -0
- data/lib/sisu/html_harvest_author_format.rb +111 -0
- data/lib/sisu/html_harvest_authors.rb +466 -0
- data/lib/sisu/html_harvest_topics.rb +893 -0
- data/lib/sisu/html_lite_shared.rb +324 -0
- data/lib/sisu/html_manifest.rb +1032 -0
- data/lib/sisu/html_minitoc.rb +230 -0
- data/lib/sisu/html_parts.rb +437 -0
- data/lib/sisu/html_persist.rb +237 -0
- data/lib/sisu/html_promo.rb +440 -0
- data/lib/sisu/html_scroll.rb +235 -0
- data/lib/sisu/html_segments.rb +716 -0
- data/lib/sisu/html_shared.rb +62 -0
- data/lib/sisu/html_table.rb +64 -0
- data/lib/sisu/html_tune.rb +301 -0
- data/lib/sisu/hub.rb +277 -0
- data/lib/sisu/hub_actions.rb +1122 -0
- data/lib/sisu/hub_loop_markup_files.rb +170 -0
- data/lib/sisu/hub_options.rb +1695 -0
- data/lib/sisu/i18n.rb +702 -0
- data/lib/sisu/manpage.rb +377 -0
- data/lib/sisu/manpage_format.rb +85 -0
- data/lib/sisu/object_munge.rb +307 -0
- data/lib/sisu/prog_text_translation.rb +1702 -0
- data/lib/sisu/qrcode.rb +754 -0
- data/lib/sisu/relaxng.rb +1153 -0
- data/lib/sisu/remote.rb +246 -0
- data/lib/sisu/rexml.rb +148 -0
- data/lib/sisu/se.rb +158 -0
- data/lib/sisu/se_cleanoutput.rb +145 -0
- data/lib/sisu/se_clear.rb +105 -0
- data/lib/sisu/se_createsite.rb +273 -0
- data/lib/sisu/se_css.rb +221 -0
- data/lib/sisu/se_date.rb +92 -0
- data/lib/sisu/se_db.rb +214 -0
- data/lib/sisu/se_envcall.rb +326 -0
- data/lib/sisu/se_file_op.rb +2758 -0
- data/lib/sisu/se_filemap.rb +247 -0
- data/lib/sisu/se_get_init.rb +238 -0
- data/lib/sisu/se_hub_particulars.rb +234 -0
- data/lib/sisu/se_info_env.rb +2179 -0
- data/lib/sisu/se_info_port.rb +70 -0
- data/lib/sisu/se_info_system.rb +202 -0
- data/lib/sisu/se_load.rb +108 -0
- data/lib/sisu/se_processing.rb +659 -0
- data/lib/sisu/se_programs.rb +394 -0
- data/lib/sisu/se_remotes.rb +553 -0
- data/lib/sisu/se_standardise_lang.rb +176 -0
- data/lib/sisu/se_version.rb +174 -0
- data/lib/sisu/shared_images.rb +137 -0
- data/lib/sisu/shared_markup_alt.rb +336 -0
- data/lib/sisu/shared_metadata.rb +1361 -0
- data/lib/sisu/shared_sem.rb +156 -0
- data/lib/sisu/sisu_thor_lib.rb +407 -0
- data/lib/sisu/sitemaps.rb +224 -0
- data/lib/sisu/src_kdissert_share.rb +102 -0
- data/lib/sisu/src_po4a_share.rb +309 -0
- data/lib/sisu/src_po4a_shelf.rb +1217 -0
- data/lib/sisu/src_po4a_shelf_set.rb +297 -0
- data/lib/sisu/src_po4a_sst_ao_sst.rb +893 -0
- data/lib/sisu/src_po4a_sst_ao_sst_set.rb +284 -0
- data/lib/sisu/src_po4a_sstm.rb +135 -0
- data/lib/sisu/src_shared.rb +347 -0
- data/lib/sisu/src_sisupod_make.rb +171 -0
- data/lib/sisu/src_sisupod_sstm.rb +109 -0
- data/lib/sisu/sst_convert_markup.rb +323 -0
- data/lib/sisu/sst_do_inline_footnotes.rb +440 -0
- data/lib/sisu/sst_from_xml.rb +178 -0
- data/lib/sisu/sst_identify_markup.rb +482 -0
- data/lib/sisu/sst_to_s_xml_sax.rb +471 -0
- data/lib/sisu/termsheet.rb +163 -0
- data/lib/sisu/texinfo.rb +430 -0
- data/lib/sisu/texinfo_format.rb +541 -0
- data/lib/sisu/texpdf.rb +1162 -0
- data/lib/sisu/texpdf_format.rb +1689 -0
- data/lib/sisu/texpdf_parts.rb +235 -0
- data/lib/sisu/txt_asciidoc.rb +354 -0
- data/lib/sisu/txt_asciidoc_decorate.rb +207 -0
- data/lib/sisu/txt_markdown.rb +389 -0
- data/lib/sisu/txt_markdown_decorate.rb +207 -0
- data/lib/sisu/txt_orgmode.rb +376 -0
- data/lib/sisu/txt_orgmode_decorate.rb +186 -0
- data/lib/sisu/txt_output.rb +86 -0
- data/lib/sisu/txt_plain.rb +410 -0
- data/lib/sisu/txt_plain_decorate.rb +189 -0
- data/lib/sisu/txt_read.rb +109 -0
- data/lib/sisu/txt_rst.rb +371 -0
- data/lib/sisu/txt_rst_decorate.rb +186 -0
- data/lib/sisu/txt_shared.rb +241 -0
- data/lib/sisu/txt_textile.rb +367 -0
- data/lib/sisu/txt_textile_decorate.rb +186 -0
- data/lib/sisu/update.rb +141 -0
- data/lib/sisu/urls.rb +696 -0
- data/lib/sisu/utils.rb +232 -0
- data/lib/sisu/utils_composite.rb +115 -0
- data/lib/sisu/utils_response.rb +114 -0
- data/lib/sisu/utils_screen_text_color.rb +472 -0
- data/lib/sisu/utils_spell.rb +99 -0
- data/lib/sisu/webrick.rb +191 -0
- data/lib/sisu/wikispeak.rb +375 -0
- data/lib/sisu/xhtml.rb +472 -0
- data/lib/sisu/xhtml_epub2.rb +890 -0
- data/lib/sisu/xhtml_epub2_concordance.rb +322 -0
- data/lib/sisu/xhtml_epub2_format.rb +2272 -0
- data/lib/sisu/xhtml_epub2_persist.rb +278 -0
- data/lib/sisu/xhtml_epub2_segments.rb +599 -0
- data/lib/sisu/xhtml_epub2_tune.rb +330 -0
- data/lib/sisu/xhtml_parts.rb +183 -0
- data/lib/sisu/xhtml_shared.rb +62 -0
- data/lib/sisu/xhtml_table.rb +97 -0
- data/lib/sisu/xml_docbook5.rb +376 -0
- data/lib/sisu/xml_dom.rb +624 -0
- data/lib/sisu/xml_fictionbook2.rb +389 -0
- data/lib/sisu/xml_format.rb +865 -0
- data/lib/sisu/xml_md_oai_pmh_dc.rb +229 -0
- data/lib/sisu/xml_odf_odt.rb +887 -0
- data/lib/sisu/xml_odf_odt_format.rb +674 -0
- data/lib/sisu/xml_parts.rb +191 -0
- data/lib/sisu/xml_persist.rb +126 -0
- data/lib/sisu/xml_sax.rb +521 -0
- data/lib/sisu/xml_scaffold_structure_collapsed.rb +198 -0
- data/lib/sisu/xml_scaffold_structure_sisu.rb +201 -0
- data/lib/sisu/xml_shared.rb +665 -0
- data/lib/sisu/xml_tables.rb +261 -0
- data/lib/sisu/zap.rb +90 -0
- metadata +251 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** extract and print an XML rendition of document structure to screen
|
|
8
|
+
|
|
9
|
+
** Author: Ralph Amissah
|
|
10
|
+
<ralph@amissah.com>
|
|
11
|
+
<ralph.amissah@gmail.com>
|
|
12
|
+
|
|
13
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
|
14
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
|
15
|
+
All Rights Reserved.
|
|
16
|
+
|
|
17
|
+
** License: GPL 3 or later:
|
|
18
|
+
|
|
19
|
+
SiSU, a framework for document structuring, publishing and search
|
|
20
|
+
|
|
21
|
+
Copyright (C) Ralph Amissah
|
|
22
|
+
|
|
23
|
+
This program is free software: you can redistribute it and/or modify it
|
|
24
|
+
under the terms of the GNU General Public License as published by the Free
|
|
25
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
|
26
|
+
any later version.
|
|
27
|
+
|
|
28
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
29
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
31
|
+
more details.
|
|
32
|
+
|
|
33
|
+
You should have received a copy of the GNU General Public License along with
|
|
34
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
35
|
+
|
|
36
|
+
If you have Internet connection, the latest version of the GPL should be
|
|
37
|
+
available at these locations:
|
|
38
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
|
39
|
+
<http://www.gnu.org/licenses/gpl.html>
|
|
40
|
+
|
|
41
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
|
42
|
+
|
|
43
|
+
** SiSU uses:
|
|
44
|
+
* Standard SiSU markup syntax,
|
|
45
|
+
* Standard SiSU meta-markup syntax, and the
|
|
46
|
+
* Standard SiSU object citation numbering and system
|
|
47
|
+
|
|
48
|
+
** Hompages:
|
|
49
|
+
<http://www.jus.uio.no/sisu>
|
|
50
|
+
<http://www.sisudoc.org>
|
|
51
|
+
|
|
52
|
+
** Git
|
|
53
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
|
54
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/xml_scaffold.rb;hb=HEAD>
|
|
55
|
+
|
|
56
|
+
=end
|
|
57
|
+
module SiSU_XML_Scaffold_Structure_Collapse
|
|
58
|
+
require_relative 'se_hub_particulars' # se_hub_particulars.rb
|
|
59
|
+
include SiSU_Particulars
|
|
60
|
+
require_relative 'ao' # ao.rb
|
|
61
|
+
require_relative 'se' # se.rb
|
|
62
|
+
include SiSU_Env
|
|
63
|
+
class Source
|
|
64
|
+
def initialize(opt)
|
|
65
|
+
@opt=opt
|
|
66
|
+
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
|
|
67
|
+
end
|
|
68
|
+
def spaces
|
|
69
|
+
Ax[:spaces]
|
|
70
|
+
end
|
|
71
|
+
def read
|
|
72
|
+
begin
|
|
73
|
+
@md,@ao_array=@particulars.md,@particulars.ao_array
|
|
74
|
+
SiSU_XML_Scaffold_Structure_Collapse::Source::Scroll.new(@ao_array,@md).songsheet
|
|
75
|
+
rescue
|
|
76
|
+
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
|
|
77
|
+
__LINE__.to_s + ':' + __FILE__
|
|
78
|
+
end
|
|
79
|
+
ensure
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
private
|
|
83
|
+
class Scroll <Source
|
|
84
|
+
def initialize(data='',md='')
|
|
85
|
+
@data,@md=data,md
|
|
86
|
+
end
|
|
87
|
+
def songsheet
|
|
88
|
+
@t='sisu'
|
|
89
|
+
data=@data
|
|
90
|
+
if @md.opt.act[:verbose_plus][:set]==:on
|
|
91
|
+
structure_collapsed(data)
|
|
92
|
+
end
|
|
93
|
+
structure_build_collapsed(data)
|
|
94
|
+
end
|
|
95
|
+
def tags
|
|
96
|
+
# collapsed -->
|
|
97
|
+
def collapsed
|
|
98
|
+
[ '0',
|
|
99
|
+
'1',
|
|
100
|
+
'2',
|
|
101
|
+
'3',
|
|
102
|
+
'4',
|
|
103
|
+
'5',
|
|
104
|
+
'6'
|
|
105
|
+
]
|
|
106
|
+
end
|
|
107
|
+
def docbook
|
|
108
|
+
end
|
|
109
|
+
def fictionbook
|
|
110
|
+
end
|
|
111
|
+
self
|
|
112
|
+
end
|
|
113
|
+
def output(o,lev=nil,comment='')
|
|
114
|
+
puts lev == (0..6) \
|
|
115
|
+
? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
|
|
116
|
+
: "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
|
|
117
|
+
end
|
|
118
|
+
def structure_collapsed(data)
|
|
119
|
+
puts "\ncollapsed structure, heading outline --->\n\n"
|
|
120
|
+
data.each_with_index do |o,i|
|
|
121
|
+
if (o.is ==:heading || o.is ==:heading_insert)
|
|
122
|
+
output(o,o.lc)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
def structure_build_collapsed(data)
|
|
127
|
+
@s=tags.collapsed
|
|
128
|
+
puts "\nXML [#{@t} type] structure outline --->\n\n"
|
|
129
|
+
h=[0,false,false,false]
|
|
130
|
+
puts "<#{@s[0]}>"
|
|
131
|
+
data.each_with_index do |o,i|
|
|
132
|
+
if (o.is ==:heading || o.is ==:heading_insert)
|
|
133
|
+
lev=o.lc
|
|
134
|
+
structure_build_tag_close(lev,h)
|
|
135
|
+
puts "#{spaces*lev}<#{@s[lev]}>\n#{spaces*lev} [#{o.ocn}] #{lev} {#{o.node}}"
|
|
136
|
+
h[0]=lev
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
structure_build_tag_close(0,h)
|
|
140
|
+
end
|
|
141
|
+
def structure_build_tag_close(lev,h)
|
|
142
|
+
case h[0]
|
|
143
|
+
when 1
|
|
144
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
|
|
145
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
146
|
+
when 2
|
|
147
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
|
|
148
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
|
|
149
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
150
|
+
when 3
|
|
151
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
|
|
152
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
|
|
153
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
|
|
154
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
155
|
+
when 4
|
|
156
|
+
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
|
|
157
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
|
|
158
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
|
|
159
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
|
|
160
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
161
|
+
when 5
|
|
162
|
+
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
|
|
163
|
+
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
|
|
164
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
|
|
165
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
|
|
166
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
|
|
167
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
168
|
+
when 6
|
|
169
|
+
puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6)
|
|
170
|
+
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
|
|
171
|
+
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
|
|
172
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3)
|
|
173
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2)
|
|
174
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1)
|
|
175
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
__END__
|
|
182
|
+
@s=['0',
|
|
183
|
+
'A',
|
|
184
|
+
'B',
|
|
185
|
+
'C',
|
|
186
|
+
'1',
|
|
187
|
+
'2',
|
|
188
|
+
'3'
|
|
189
|
+
]
|
|
190
|
+
#@t='docbook' #@t='fictionbook'
|
|
191
|
+
#@s=['book', #@s=['body',
|
|
192
|
+
# 'part', # 'section',
|
|
193
|
+
# 'subpart N/A', # 'section',
|
|
194
|
+
# 'sub-subpart N/A', # 'section',
|
|
195
|
+
# 'chapter', # 'section',
|
|
196
|
+
# 'sect1', # 'section',
|
|
197
|
+
# 'sect2' # 'section'
|
|
198
|
+
#] #]
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** extract and print an XML rendition of document structure to screen
|
|
8
|
+
|
|
9
|
+
** Author: Ralph Amissah
|
|
10
|
+
<ralph@amissah.com>
|
|
11
|
+
<ralph.amissah@gmail.com>
|
|
12
|
+
|
|
13
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
|
14
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
|
15
|
+
All Rights Reserved.
|
|
16
|
+
|
|
17
|
+
** License: GPL 3 or later:
|
|
18
|
+
|
|
19
|
+
SiSU, a framework for document structuring, publishing and search
|
|
20
|
+
|
|
21
|
+
Copyright (C) Ralph Amissah
|
|
22
|
+
|
|
23
|
+
This program is free software: you can redistribute it and/or modify it
|
|
24
|
+
under the terms of the GNU General Public License as published by the Free
|
|
25
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
|
26
|
+
any later version.
|
|
27
|
+
|
|
28
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
29
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
31
|
+
more details.
|
|
32
|
+
|
|
33
|
+
You should have received a copy of the GNU General Public License along with
|
|
34
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
35
|
+
|
|
36
|
+
If you have Internet connection, the latest version of the GPL should be
|
|
37
|
+
available at these locations:
|
|
38
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
|
39
|
+
<http://www.gnu.org/licenses/gpl.html>
|
|
40
|
+
|
|
41
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
|
42
|
+
|
|
43
|
+
** SiSU uses:
|
|
44
|
+
* Standard SiSU markup syntax,
|
|
45
|
+
* Standard SiSU meta-markup syntax, and the
|
|
46
|
+
* Standard SiSU object citation numbering and system
|
|
47
|
+
|
|
48
|
+
** Hompages:
|
|
49
|
+
<http://www.jus.uio.no/sisu>
|
|
50
|
+
<http://www.sisudoc.org>
|
|
51
|
+
|
|
52
|
+
** Git
|
|
53
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
|
54
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/xml_scaffold.rb;hb=HEAD>
|
|
55
|
+
|
|
56
|
+
=end
|
|
57
|
+
module SiSU_XML_Scaffold_Structure_Sisu
|
|
58
|
+
require_relative 'se_hub_particulars' # se_hub_particulars.rb
|
|
59
|
+
include SiSU_Particulars
|
|
60
|
+
require_relative 'ao' # ao.rb
|
|
61
|
+
require_relative 'se' # se.rb
|
|
62
|
+
include SiSU_Env
|
|
63
|
+
class Source
|
|
64
|
+
def initialize(opt)
|
|
65
|
+
@opt=opt
|
|
66
|
+
@particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
|
|
67
|
+
end
|
|
68
|
+
def spaces
|
|
69
|
+
Ax[:spaces]
|
|
70
|
+
end
|
|
71
|
+
def read
|
|
72
|
+
begin
|
|
73
|
+
@md,@ao_array=@particulars.md,@particulars.ao_array
|
|
74
|
+
SiSU_XML_Scaffold_Structure_Sisu::Source::Scroll.new(@ao_array,@md).songsheet
|
|
75
|
+
rescue
|
|
76
|
+
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
|
|
77
|
+
__LINE__.to_s + ':' + __FILE__
|
|
78
|
+
end
|
|
79
|
+
ensure
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
private
|
|
83
|
+
class Scroll <Source
|
|
84
|
+
def initialize(data='',md='')
|
|
85
|
+
@data,@md=data,md
|
|
86
|
+
end
|
|
87
|
+
def songsheet
|
|
88
|
+
@t='sisu'
|
|
89
|
+
data=@data
|
|
90
|
+
if @md.opt.act[:verbose_plus][:set]==:on
|
|
91
|
+
structure_sisu_simple(data)
|
|
92
|
+
end
|
|
93
|
+
structure_build_sisu(data)
|
|
94
|
+
end
|
|
95
|
+
def tags
|
|
96
|
+
def sisu
|
|
97
|
+
[ '0',
|
|
98
|
+
'A',
|
|
99
|
+
'B',
|
|
100
|
+
'C',
|
|
101
|
+
'1',
|
|
102
|
+
'2',
|
|
103
|
+
'3'
|
|
104
|
+
]
|
|
105
|
+
end
|
|
106
|
+
self
|
|
107
|
+
end
|
|
108
|
+
def structure_sisu_simple(data)
|
|
109
|
+
puts "\nsisu structure, heading outline --->\n\n"
|
|
110
|
+
data.each_with_index do |o,i|
|
|
111
|
+
if (o.is ==:heading || o.is ==:heading_insert)
|
|
112
|
+
puts "#{spaces*o.ln}<#{tags.sisu[o.ln]}>[#{o.ocn}] #{o.ln} #{o.obj}</#{tags.sisu[o.ln]}>"
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
def output(o,lev=nil,comment='')
|
|
117
|
+
puts lev == (0..6) \
|
|
118
|
+
? "#{spaces*lev}<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
|
|
119
|
+
: "<#{lev}>[#{o.ocn}] #{o.ln} #{o.obj}</#{lev}>#{comment}"
|
|
120
|
+
end
|
|
121
|
+
def structure_build_sisu(data)
|
|
122
|
+
@s=tags.sisu
|
|
123
|
+
puts "\nXML [#{@t} type] structure outline --->\n\n"
|
|
124
|
+
h=[0,false,false,false]
|
|
125
|
+
puts "<#{@s[0]}>"
|
|
126
|
+
data.each_with_index do |o,i|
|
|
127
|
+
if (o.is ==:heading || o.is ==:heading_insert)
|
|
128
|
+
structure_build_tag_close(o.ln,h)
|
|
129
|
+
puts "#{spaces*o.ln}<#{@s[o.ln]}>\n#{spaces*o.ln} [#{o.ocn}] #{o.ln} {#{o.node}}"
|
|
130
|
+
case o.ln
|
|
131
|
+
when 1
|
|
132
|
+
h=[o.ln,true,false,false]
|
|
133
|
+
when 2
|
|
134
|
+
h=[o.ln,true,true,false]
|
|
135
|
+
when 3
|
|
136
|
+
h=[o.ln,true,true,true]
|
|
137
|
+
when 4..6
|
|
138
|
+
h[0]=o.ln
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
structure_build_tag_close(0,h)
|
|
143
|
+
end
|
|
144
|
+
def structure_build_tag_close(lev,h)
|
|
145
|
+
case h[0]
|
|
146
|
+
when 1
|
|
147
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
|
|
148
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
149
|
+
when 2
|
|
150
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
|
|
151
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
|
|
152
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
153
|
+
when 3
|
|
154
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
|
|
155
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
|
|
156
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
|
|
157
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
158
|
+
when 4
|
|
159
|
+
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
|
|
160
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
|
|
161
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
|
|
162
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
|
|
163
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
164
|
+
when 5
|
|
165
|
+
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
|
|
166
|
+
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
|
|
167
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
|
|
168
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
|
|
169
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
|
|
170
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
171
|
+
when 6
|
|
172
|
+
puts "#{spaces*6}</#{@s[6]}>" if (lev <= 6)
|
|
173
|
+
puts "#{spaces*5}</#{@s[5]}>" if (lev <= 5)
|
|
174
|
+
puts "#{spaces*4}</#{@s[4]}>" if (lev <= 4)
|
|
175
|
+
puts "#{spaces*3}</#{@s[3]}>" if (lev <= 3) && h[3]
|
|
176
|
+
puts "#{spaces*2}</#{@s[2]}>" if (lev <= 2) && h[2]
|
|
177
|
+
puts "#{spaces*1}</#{@s[1]}>" if (lev <= 1) && h[1]
|
|
178
|
+
puts "</#{@s[0]}>" if (lev==0)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
__END__
|
|
185
|
+
@s=['0',
|
|
186
|
+
'A',
|
|
187
|
+
'B',
|
|
188
|
+
'C',
|
|
189
|
+
'1',
|
|
190
|
+
'2',
|
|
191
|
+
'3'
|
|
192
|
+
]
|
|
193
|
+
#@t='docbook' #@t='fictionbook'
|
|
194
|
+
#@s=['book', #@s=['body',
|
|
195
|
+
# 'part', # 'section',
|
|
196
|
+
# 'subpart N/A', # 'section',
|
|
197
|
+
# 'sub-subpart N/A', # 'section',
|
|
198
|
+
# 'chapter', # 'section',
|
|
199
|
+
# 'sect1', # 'section',
|
|
200
|
+
# 'sect2' # 'section'
|
|
201
|
+
#] #]
|
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** common file for xml generation
|
|
8
|
+
|
|
9
|
+
** Author: Ralph Amissah
|
|
10
|
+
|
|
11
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
|
12
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
|
13
|
+
All Rights Reserved.
|
|
14
|
+
|
|
15
|
+
** License: GPL 3 or later:
|
|
16
|
+
|
|
17
|
+
SiSU, a framework for document structuring, publishing and search
|
|
18
|
+
|
|
19
|
+
Copyright (C) Ralph Amissah
|
|
20
|
+
|
|
21
|
+
This program is free software: you can redistribute it and/or modify it
|
|
22
|
+
under the terms of the GNU General Public License as published by the Free
|
|
23
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
|
24
|
+
any later version.
|
|
25
|
+
|
|
26
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
27
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
29
|
+
more details.
|
|
30
|
+
|
|
31
|
+
You should have received a copy of the GNU General Public License along with
|
|
32
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
33
|
+
|
|
34
|
+
If you have Internet connection, the latest version of the GPL should be
|
|
35
|
+
available at these locations:
|
|
36
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
|
37
|
+
<http://www.gnu.org/licenses/gpl.html>
|
|
38
|
+
|
|
39
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
|
40
|
+
|
|
41
|
+
** SiSU uses:
|
|
42
|
+
* Standard SiSU markup syntax,
|
|
43
|
+
* Standard SiSU meta-markup syntax, and the
|
|
44
|
+
* Standard SiSU object citation numbering and system
|
|
45
|
+
|
|
46
|
+
** Hompages:
|
|
47
|
+
<http://www.jus.uio.no/sisu>
|
|
48
|
+
<http://www.sisudoc.org>
|
|
49
|
+
|
|
50
|
+
** Git
|
|
51
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
|
52
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/xml_shared.rb;hb=HEAD>
|
|
53
|
+
|
|
54
|
+
** Ralph Amissah
|
|
55
|
+
<ralph@amissah.com>
|
|
56
|
+
<ralph.amissah@gmail.com>
|
|
57
|
+
|
|
58
|
+
=end
|
|
59
|
+
module SiSU_XML_Munge
|
|
60
|
+
require_relative 'xml_parts' # xml_parts.rb
|
|
61
|
+
class Trans
|
|
62
|
+
include SiSU_Parts_XML
|
|
63
|
+
def initialize(md)
|
|
64
|
+
@md=md
|
|
65
|
+
@sys=SiSU_Env::SystemCall.new
|
|
66
|
+
@dir=SiSU_Env::InfoEnv.new(@md.fns)
|
|
67
|
+
if @md.sem_tag
|
|
68
|
+
@ab ||=semantic_tags.default
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
def semantic_tags
|
|
72
|
+
def default
|
|
73
|
+
{
|
|
74
|
+
pub: 'publication',
|
|
75
|
+
conv: 'convention',
|
|
76
|
+
vol: 'volume',
|
|
77
|
+
pg: 'page',
|
|
78
|
+
cty: 'city',
|
|
79
|
+
org: 'organization',
|
|
80
|
+
uni: 'university',
|
|
81
|
+
dept: 'department',
|
|
82
|
+
fac: 'faculty',
|
|
83
|
+
inst: 'institute',
|
|
84
|
+
co: 'company',
|
|
85
|
+
com: 'company',
|
|
86
|
+
conv: 'convention',
|
|
87
|
+
dt: 'date',
|
|
88
|
+
y: 'year',
|
|
89
|
+
m: 'month',
|
|
90
|
+
d: 'day',
|
|
91
|
+
ti: 'title',
|
|
92
|
+
au: 'author',
|
|
93
|
+
ed: 'editor', #editor?
|
|
94
|
+
v: 'version', #edition
|
|
95
|
+
n: 'name',
|
|
96
|
+
fn: 'firstname',
|
|
97
|
+
mn: 'middlename',
|
|
98
|
+
ln: 'lastname',
|
|
99
|
+
in: 'initials',
|
|
100
|
+
qt: 'quote',
|
|
101
|
+
ct: 'cite',
|
|
102
|
+
ref: 'reference',
|
|
103
|
+
ab: 'abreviation',
|
|
104
|
+
def: 'define',
|
|
105
|
+
desc: 'description',
|
|
106
|
+
trans: 'translate',
|
|
107
|
+
}
|
|
108
|
+
end
|
|
109
|
+
self
|
|
110
|
+
end
|
|
111
|
+
def char_enc #character encode
|
|
112
|
+
def utf8(dob='')
|
|
113
|
+
if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
|
|
114
|
+
str=if defined? dob.obj then dob.obj
|
|
115
|
+
elsif dob.is_a?(String) then dob
|
|
116
|
+
end
|
|
117
|
+
if str
|
|
118
|
+
#¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü
|
|
119
|
+
#¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷
|
|
120
|
+
str=str.gsub(/</um,'<'). # '<' # <
|
|
121
|
+
gsub(/>/um,'>'). # '>' # >
|
|
122
|
+
gsub(/¢/um,'¢'). # '¢' # ¢
|
|
123
|
+
gsub(/£/um,'£'). # '£' # £
|
|
124
|
+
gsub(/¥/um,'¥'). # '¥' # ¥
|
|
125
|
+
gsub(/§/um,'§'). # '§' # §
|
|
126
|
+
gsub(/©/um,'©'). # '©' # ©
|
|
127
|
+
gsub(/ª/um,'ª'). # 'ª' # ª
|
|
128
|
+
gsub(/«/um,'«'). # '«' # «
|
|
129
|
+
gsub(/®/um,'®'). # '®' # ®
|
|
130
|
+
gsub(/°/um,'°'). # '°' # °
|
|
131
|
+
gsub(/±/um,'±'). # '±' # ±
|
|
132
|
+
gsub(/²/um,'²'). # '²' # ²
|
|
133
|
+
gsub(/³/um,'³'). # '³' # ³
|
|
134
|
+
gsub(/µ/um,'µ'). # 'µ' # µ
|
|
135
|
+
gsub(/¶/um,'¶'). # '¶' # ¶
|
|
136
|
+
gsub(/¹/um,'¹'). # '¹' # ¹
|
|
137
|
+
gsub(/º/um,'º'). # 'º' # º
|
|
138
|
+
gsub(/»/um,'»'). # '»' # »
|
|
139
|
+
gsub(/¼/um,'¼'). # '¼' # ¼
|
|
140
|
+
gsub(/½/um,'½'). # '½' # ½
|
|
141
|
+
gsub(/¾/um,'¾'). # '¾' # ¾
|
|
142
|
+
gsub(/×/um,'×'). # '×' # ×
|
|
143
|
+
gsub(/÷/um,'÷'). # '÷' # ÷
|
|
144
|
+
gsub(/¿/um,'¿'). # '¿' # ¿
|
|
145
|
+
gsub(/À/um,'À'). # 'À' # À
|
|
146
|
+
gsub(/Á/um,'Á'). # 'Á' # Á
|
|
147
|
+
gsub(/Â/um,'Â'). # 'Â' # Â
|
|
148
|
+
gsub(/Ã/um,'Ã'). # 'Ã' # Ã
|
|
149
|
+
gsub(/Ä/um,'Ä'). # 'Ä' # Ä
|
|
150
|
+
gsub(/Å/um,'Å'). # 'Å' # Å
|
|
151
|
+
gsub(/Æ/um,'Æ'). # 'Æ' # Æ
|
|
152
|
+
gsub(/Ç/um,'Ç'). # 'Ç' # Ç
|
|
153
|
+
gsub(/È/um,'È'). # 'È' # È
|
|
154
|
+
gsub(/É/um,'É'). # 'É' # É
|
|
155
|
+
gsub(/Ê/um,'Ê'). # 'Ê' # Ê
|
|
156
|
+
gsub(/Ë/um,'Ë'). # 'Ë' # Ë
|
|
157
|
+
gsub(/Ì/um,'Ì'). # 'Ì' # Ì
|
|
158
|
+
gsub(/Í/um,'Í'). # 'Í' # Í
|
|
159
|
+
gsub(/Î/um,'Î'). # 'Î' # Î
|
|
160
|
+
gsub(/Ï/um,'Ï'). # 'Ï' # Ï
|
|
161
|
+
gsub(/Ð/um,'Ð'). # 'Ð' # Ð
|
|
162
|
+
gsub(/Ñ/um,'Ñ'). # 'Ñ' # Ñ
|
|
163
|
+
gsub(/Ò/um,'Ò'). # 'Ò' # Ò
|
|
164
|
+
gsub(/Ó/um,'Ó'). # 'Ó' # Ó
|
|
165
|
+
gsub(/Ô/um,'Ô'). # 'Ô' # Ô
|
|
166
|
+
gsub(/Õ/um,'Õ'). # 'Õ' # Õ
|
|
167
|
+
gsub(/Ö/um,'Ö'). # 'Ö' # Ö
|
|
168
|
+
gsub(/Ø/um,'Ø'). # 'Ø' # Ø
|
|
169
|
+
gsub(/Ù/um,'Ù'). # 'Ù' # Ù
|
|
170
|
+
gsub(/Ú/um,'Ú'). # 'Ú' # Ú
|
|
171
|
+
gsub(/Û/um,'Û'). # 'Û' # Û
|
|
172
|
+
gsub(/Ü/um,'Ü'). # 'Ü' # Ü
|
|
173
|
+
gsub(/Ý/um,'Ý'). # 'Ý' # Ý
|
|
174
|
+
gsub(/Þ/um,'Þ'). # 'Þ' # Þ
|
|
175
|
+
gsub(/ß/um,'ß'). # 'ß' # ß
|
|
176
|
+
gsub(/à/um,'à'). # 'à' # à
|
|
177
|
+
gsub(/á/um,'á'). # 'á' # á
|
|
178
|
+
gsub(/â/um,'â'). # 'â' # â
|
|
179
|
+
gsub(/ã/um,'ã'). # 'ã' # ã
|
|
180
|
+
gsub(/ä/um,'ä'). # 'ä' # ä
|
|
181
|
+
gsub(/å/um,'å'). # 'å' # å
|
|
182
|
+
gsub(/æ/um,'æ'). # 'æ' # æ
|
|
183
|
+
gsub(/ç/um,'ç'). # 'ç' # ç
|
|
184
|
+
gsub(/è/um,'è'). # 'è' # è
|
|
185
|
+
gsub(/é/um,'é'). # '´' # é
|
|
186
|
+
gsub(/ê/um,'ê'). # 'ˆ' # ê
|
|
187
|
+
gsub(/ë/um,'ë'). # 'ë' # ë
|
|
188
|
+
gsub(/ì/um,'ì'). # 'ì' # ì
|
|
189
|
+
gsub(/í/um,'í'). # '´' # í
|
|
190
|
+
gsub(/î/um,'î'). # 'î' # î
|
|
191
|
+
gsub(/ï/um,'ï'). # 'ï' # ï
|
|
192
|
+
gsub(/ð/um,'ð'). # 'ð' # ð
|
|
193
|
+
gsub(/ñ/um,'ñ'). # 'ñ' # ñ
|
|
194
|
+
gsub(/ò/um,'ò'). # 'ò' # ò
|
|
195
|
+
gsub(/ó/um,'ó'). # 'ó' # ó
|
|
196
|
+
gsub(/ô/um,'ô'). # 'ô' # ô
|
|
197
|
+
gsub(/õ/um,'õ'). # 'õ' # õ
|
|
198
|
+
gsub(/ö/um,'ö'). # 'ö' # ö
|
|
199
|
+
gsub(/ø/um,'ø'). # 'ø' # ø
|
|
200
|
+
gsub(/ù/um,'ú'). # 'ù' # ú
|
|
201
|
+
gsub(/ú/um,'û'). # 'ú' # û
|
|
202
|
+
gsub(/û/um,'ü'). # 'û' # ü
|
|
203
|
+
gsub(/ü/um,'ý'). # 'ü' # ý
|
|
204
|
+
gsub(/þ/um,'þ'). # 'þ' # þ
|
|
205
|
+
gsub(/ÿ/um,'ÿ'). # 'ÿ' # ÿ
|
|
206
|
+
gsub(/‘/um,'‘'). # '‘' # ‘
|
|
207
|
+
gsub(/’/um,'’'). # '’' # ’
|
|
208
|
+
gsub(/“/um,'“'). # “ # “
|
|
209
|
+
gsub(/”/um,'”'). # ” # ”
|
|
210
|
+
gsub(/–/um,'–'). # – # –
|
|
211
|
+
gsub(/—/um,'—'). # — # —
|
|
212
|
+
gsub(/∝/um,'∝'). # ∝ # ∝
|
|
213
|
+
gsub(/∞/um,'∞'). # ∞ # ∞
|
|
214
|
+
gsub(/™/um,'™'). # ™ # ™
|
|
215
|
+
gsub(/✠/um,'✠'). # ✗ # ✠
|
|
216
|
+
gsub(/ /um,' '). # space identify
|
|
217
|
+
gsub(/ /um,' ') # space identify
|
|
218
|
+
end
|
|
219
|
+
dob=if defined? dob.obj
|
|
220
|
+
dob.obj=str
|
|
221
|
+
dob
|
|
222
|
+
elsif dob.is_a?(String)
|
|
223
|
+
str
|
|
224
|
+
end
|
|
225
|
+
dob
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
def html(dob='')
|
|
229
|
+
if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
|
|
230
|
+
dob.obj=dob.obj.gsub(/ /u,' '). # space identify
|
|
231
|
+
gsub(/ /u,' ') # space identify
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
self
|
|
235
|
+
end
|
|
236
|
+
def tidywords(wordlist)
|
|
237
|
+
wordlist_new=[]
|
|
238
|
+
wordlist.each do |x|
|
|
239
|
+
#imperfect solution will not catch all possible cases
|
|
240
|
+
x=x.gsub(/&/,'&') unless x =~/&\S+;/
|
|
241
|
+
x=x.gsub(/&([A-Z])/,'&\1')
|
|
242
|
+
wordlist_new << x
|
|
243
|
+
end
|
|
244
|
+
wordlist_new
|
|
245
|
+
end
|
|
246
|
+
def markup(dob='')
|
|
247
|
+
wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17
|
|
248
|
+
dob.obj=tidywords(wordlist).join(' ').strip
|
|
249
|
+
unless dob.is==:table
|
|
250
|
+
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/u,'<br />').
|
|
251
|
+
gsub(/#{Mx[:br_paragraph]}/u,'<br />').
|
|
252
|
+
gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />')
|
|
253
|
+
end
|
|
254
|
+
dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'').
|
|
255
|
+
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
|
|
256
|
+
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').
|
|
257
|
+
gsub(/(^|#{Mx[:gl_c]}|\s+)<\s+/,'\1< ').gsub(/\s+>(\s+|$)/,' >\1').
|
|
258
|
+
#gsub(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'<em>\1</em>'). #reinstate
|
|
259
|
+
gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'<b>\1</b>').
|
|
260
|
+
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'<i>\1</i>').
|
|
261
|
+
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
|
|
262
|
+
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
|
|
263
|
+
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
|
|
264
|
+
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
|
|
265
|
+
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
|
|
266
|
+
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
|
|
267
|
+
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>').
|
|
268
|
+
gsub(/<:pb>\s*/,''). #Fix
|
|
269
|
+
gsub(/<+[-~]#>+/,'')
|
|
270
|
+
if dob.is !=:code
|
|
271
|
+
#embeds a red-bullet image -->
|
|
272
|
+
dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
|
|
273
|
+
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
|
|
274
|
+
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
|
|
275
|
+
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>')
|
|
276
|
+
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
|
|
277
|
+
dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*/,'').
|
|
278
|
+
gsub(/#{Mx[:br_page_new]}\s*/,'').
|
|
279
|
+
gsub(/#{Mx[:br_page_line]}\s*/,'').
|
|
280
|
+
gsub(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,'').
|
|
281
|
+
gsub(/<[-~]#>/,'').
|
|
282
|
+
gsub(/href="#{Xx[:segment]}/m,'href="').
|
|
283
|
+
gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/,
|
|
284
|
+
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\2">\1</link>').
|
|
285
|
+
gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/,
|
|
286
|
+
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="../\2">\1</link>').
|
|
287
|
+
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/,
|
|
288
|
+
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="#\2">\1</link>').
|
|
289
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
|
|
290
|
+
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}).
|
|
291
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
|
|
292
|
+
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}).
|
|
293
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/,
|
|
294
|
+
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}).
|
|
295
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/,
|
|
296
|
+
%{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}).
|
|
297
|
+
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
|
|
298
|
+
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\2">\1</link>'). #watch, compare html_tune
|
|
299
|
+
gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
|
|
300
|
+
%{#{the_url_decoration.xml_open}<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\\1">\\1</link>#{the_url_decoration.xml_close}}).
|
|
301
|
+
gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
|
|
302
|
+
'<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\1">\1</link>') #escaped urls not linked, deal with later
|
|
303
|
+
else
|
|
304
|
+
dob.obj=dob.obj.gsub(/</m,'<').gsub(/>/m,'>')
|
|
305
|
+
end
|
|
306
|
+
if dob.of==:block
|
|
307
|
+
dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ')
|
|
308
|
+
end
|
|
309
|
+
dob.obj=dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
|
|
310
|
+
%{#{the_url_decoration.xml_open}\\1#{the_url_decoration.xml_close}}).
|
|
311
|
+
gsub(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}").
|
|
312
|
+
gsub(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}").
|
|
313
|
+
gsub(/ |#{Mx[:nbsp]}/m,' ').
|
|
314
|
+
gsub(/;&([^#]|(?:[^gl][^t]|[^a][^m][^p]|[^n][^b][^s][^p])[^;])/,';&\1') # pattern not to match
|
|
315
|
+
dob
|
|
316
|
+
end
|
|
317
|
+
def markup_light(dob='')
|
|
318
|
+
dob.obj=dob.obj.gsub(/\/\{(.+?)\}\//,'<i>\1</i>').
|
|
319
|
+
gsub(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>').
|
|
320
|
+
gsub(/_\{(.+?)\}_/,'<u>\1</u>').
|
|
321
|
+
gsub(/-\{(.+?)\}-/,'<del>\1</del>').
|
|
322
|
+
gsub(/<br(\s*\/)?>/,'<br />').
|
|
323
|
+
gsub(/<:pb>\s*/,'').
|
|
324
|
+
gsub(/<[-~]#>/,'').
|
|
325
|
+
gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort
|
|
326
|
+
gsub(/&([^;]{1,5})/,'&\1'). #sort, rough estimate, revisit #WATCH found in node not sax
|
|
327
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,
|
|
328
|
+
"<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>").
|
|
329
|
+
gsub(/ |#{Mx[:nbsp]}/,' ').
|
|
330
|
+
gsub(/;&([^#]|(?:[^gl][^t]|[^a][^m][^p]|[^n][^b][^s][^p])[^;])/,';&\1') # pattern not to match
|
|
331
|
+
wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17
|
|
332
|
+
dob.obj=tidywords(wordlist).join(' ').strip
|
|
333
|
+
dob
|
|
334
|
+
end
|
|
335
|
+
def clean(str)
|
|
336
|
+
str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;').
|
|
337
|
+
gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
|
|
338
|
+
end
|
|
339
|
+
def markup_fictionbook(str='',is='')
|
|
340
|
+
str=str.gsub(/#{Mx[:en_a_o]}([\d+*]+).+?#{Mx[:en_a_c]}/m,'<a xl:href="#footnote\1" type="note">[\1]</a>').
|
|
341
|
+
gsub(/&/,'&'). #sort
|
|
342
|
+
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
|
|
343
|
+
gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort
|
|
344
|
+
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
|
|
345
|
+
str=str.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless is==:table
|
|
346
|
+
str=str.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
|
|
347
|
+
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
|
|
348
|
+
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
|
|
349
|
+
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
|
|
350
|
+
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
|
|
351
|
+
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
|
|
352
|
+
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
|
|
353
|
+
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
|
|
354
|
+
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
|
|
355
|
+
gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,'<image xl:href="#\1" />').
|
|
356
|
+
gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}").
|
|
357
|
+
gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
|
|
358
|
+
gsub(/#{Mx[:gl_bullet]}/m,'● '). # not available
|
|
359
|
+
gsub(/#{Mx[:nbsp]}/,' '). # not available
|
|
360
|
+
gsub(/<(p|br)>/,'<\1 />')
|
|
361
|
+
clean(str)
|
|
362
|
+
end
|
|
363
|
+
def markup_docbook(dob='') # work on, initially a copy of fictionbook!
|
|
364
|
+
if dob.is !=:code
|
|
365
|
+
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s*(.+?)#{Mx[:en_a_c]}/m,'<footnote><para><!-- fn\1 -->\2</para></footnote>').
|
|
366
|
+
gsub(/\\\\/,'</para><para>').
|
|
367
|
+
gsub(/&/,'&'). #sort
|
|
368
|
+
gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
|
|
369
|
+
gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& '). #sort
|
|
370
|
+
gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
|
|
371
|
+
dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table
|
|
372
|
+
dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
|
|
373
|
+
gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
|
|
374
|
+
gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
|
|
375
|
+
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
|
|
376
|
+
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
|
|
377
|
+
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
|
|
378
|
+
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
|
|
379
|
+
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
|
|
380
|
+
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
|
|
381
|
+
gsub(/#{Mx[:lnk_o]}\s*(\S+?)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,
|
|
382
|
+
%{#{Xx[:split]}:spaces0:<figure id="fig-\\1">\n:spaces1:<title></title>\n:spaces1:<graphic fileref="../../_sisu/image/\\1.\\2" align="center" width="50%"></graphic>\n:spaces0:</figure>#{Xx[:split]}}). # common image location, else use ./images
|
|
383
|
+
gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,
|
|
384
|
+
'<ulink url="\2">\1</ulink>').
|
|
385
|
+
gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,
|
|
386
|
+
'<ulink url="\1">\1</ulink>').
|
|
387
|
+
gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
|
|
388
|
+
gsub(/#{Mx[:gl_bullet]}/m,'● '). # not available
|
|
389
|
+
gsub(/#{Mx[:nbsp]}/,' '). # not available
|
|
390
|
+
gsub(/<(p|br)>/,'<\1 />')
|
|
391
|
+
dob.obj=clean(dob.obj)
|
|
392
|
+
elsif dob.is == :code
|
|
393
|
+
dob.obj=dob.obj.gsub(/&/m,'&'). #sort
|
|
394
|
+
gsub(/</,'<').gsub(/>/,'>')
|
|
395
|
+
else # p dob.is ??
|
|
396
|
+
end
|
|
397
|
+
dob
|
|
398
|
+
end
|
|
399
|
+
def markup_group(dob='')
|
|
400
|
+
dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>').
|
|
401
|
+
gsub(/<:?br(?:\s+\/)?>/,'<br />').
|
|
402
|
+
gsub(/<(link xmlns:xl=".+?")>/,'<\1>').
|
|
403
|
+
gsub(/<(\/link)>/,'<\1>').
|
|
404
|
+
gsub(/<(\/?en)>/,'<\1>')
|
|
405
|
+
dob
|
|
406
|
+
end
|
|
407
|
+
def markup_block(dob='')
|
|
408
|
+
dob.obj=dob.obj.gsub(/</,'<').gsub(/>/,'>').
|
|
409
|
+
gsub(/<:?br(?:\s+\/)?>/,'<br />').
|
|
410
|
+
gsub(/<(link xmlns:xl=".+?")>/,'<\1>').
|
|
411
|
+
gsub(/<(\/link)>/,'<\1>').
|
|
412
|
+
gsub(/<(\/?en)>/,'<\1>')
|
|
413
|
+
dob
|
|
414
|
+
end
|
|
415
|
+
def xml_sem_block_paired(matched) # colon depth: many, recurs
|
|
416
|
+
matched=matched.gsub(/\b(au):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:au]} depth="many">\\2</sem:#{@ab[:au]}>}).
|
|
417
|
+
gsub(/\b(vol):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:vol]} depth="many">\\2</sem:#{@ab[:vol]}>}).
|
|
418
|
+
gsub(/\b(pub):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:pub]} depth="many">\\2</sem:#{@ab[:pub]}>}).
|
|
419
|
+
gsub(/\b(ref):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ref]} depth="many">\\2</sem:#{@ab[:ref]}>}).
|
|
420
|
+
gsub(/\b(desc):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:desc]} depth="many">\\2</sem:#{@ab[:desc]}>}).
|
|
421
|
+
gsub(/\b(conv):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:conv]} depth="many">\\2</sem:#{@ab[:conv]}>}).
|
|
422
|
+
gsub(/\b(ct):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ct]} depth="many">\\2</sem:#{@ab[:ct]}>}).
|
|
423
|
+
gsub(/\b(cty):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:cty]} depth="many">\\2</sem:#{@ab[:cty]}>}).
|
|
424
|
+
gsub(/\b(org):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:org]} depth="many">\\2</sem:#{@ab[:org]}>}).
|
|
425
|
+
gsub(/\b(dt):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:dt]} depth="many">\\2</sem:#{@ab[:dt]}>}).
|
|
426
|
+
gsub(/\b(n):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:n]} depth="many">\\2</sem:#{@ab[:n]}>}).
|
|
427
|
+
gsub(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'<sem:\1 depth="many">\2</sem:\1>')
|
|
428
|
+
end
|
|
429
|
+
def xml_semantic_tags(dob)
|
|
430
|
+
if @md.sem_tag
|
|
431
|
+
dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
|
|
432
|
+
dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
|
|
433
|
+
dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
|
|
434
|
+
dob.obj=dob.obj.gsub(/:\{(.+?)\}:au\b/m, %{<sem:#{@ab[:au]} depth="one">\\1</sem:#{@ab[:au]}>}).
|
|
435
|
+
gsub(/:\{(.+?)\}:n\b/m, %{<sem:#{@ab[:n]} depth="one">\\1</sem:#{@ab[:n]}>}).
|
|
436
|
+
gsub(/:\{(.+?)\}:ti\b/m, %{<sem:#{@ab[:ti]} depth="one">\\1</sem:#{@ab[:ti]}>}).
|
|
437
|
+
gsub(/:\{(.+?)\}:ref\b/m, %{<sem:#{@ab[:ref]} depth="one">\\1</sem:#{@ab[:ref]}>}).
|
|
438
|
+
gsub(/:\{(.+?)\}:desc\b/m, %{<sem:#{@ab[:desc]} depth="one">\\1</sem:#{@ab[:desc]}>}).
|
|
439
|
+
gsub(/:\{(.+?)\}:cty\b/m, %{<sem:#{@ab[:cty]} depth="one">\\1</sem:#{@ab[:cty]}>}).
|
|
440
|
+
gsub(/:\{(.+?)\}:org\b/m, %{<sem:#{@ab[:org]} depth="one">\\1</sem:#{@ab[:org]}>}).
|
|
441
|
+
gsub(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="one">\1</sem:\2>').
|
|
442
|
+
gsub(/;\{([^}]+(?![;]))\};ti\b/m, %{<sem:#{@ab[:ti]} depth="zero">\\1</sem:#{@ab[:ti]}>}).
|
|
443
|
+
gsub(/;\{([^}]+(?![;]))\};qt\b/m, %{<sem:#{@ab[:qt]} depth="zero">\\1</sem:#{@ab[:qt]}>}).
|
|
444
|
+
gsub(/;\{([^}]+(?![;]))\};ref\b/m, %{<sem:#{@ab[:ref]} depth="zero">\\1</sem:#{@ab[:ref]}>}).
|
|
445
|
+
gsub(/;\{([^}]+(?![;]))\};ed\b/m, %{<sem:#{@ab[:ed]} depth="zero">\\1</sem:#{@ab[:ed]}>}).
|
|
446
|
+
gsub(/;\{([^}]+(?![;]))\};v\b/m, %{<sem:#{@ab[:v]} depth="zero">\\1</sem:#{@ab[:v]}>}).
|
|
447
|
+
gsub(/;\{([^}]+(?![;]))\};desc\b/m, %{<sem:#{@ab[:desc]} depth="zero">\\1</sem:#{@ab[:desc]}>}).
|
|
448
|
+
gsub(/;\{([^}]+(?![;]))\};def\b/m, %{<sem:#{@ab[:def]} depth="zero">\\1</sem:#{@ab[:def]}>}).
|
|
449
|
+
gsub(/;\{([^}]+(?![;]))\};trans\b/m, %{<sem:#{@ab[:trans]} depth="zero">\\1</sem:#{@ab[:trans]}>}).
|
|
450
|
+
gsub(/;\{([^}]+(?![;]))\};y\b/m, %{<sem:#{@ab[:y]} depth="zero">\\1</sem:#{@ab[:y]}>}).
|
|
451
|
+
gsub(/;\{([^}]+(?![;]))\};ab\b/m, %{<sem:#{@ab[:ab]} depth="zero">\\1</sem:#{@ab[:ab]}>}).
|
|
452
|
+
gsub(/;\{([^}]+(?![;]))\};pg\b/m, %{<sem:#{@ab[:pg]} depth="zero">\\1</sem:#{@ab[:pg]}>}).
|
|
453
|
+
gsub(/;\{([^}]+(?![;]))\};fn?\b/m, %{<sem:#{@ab[:fn]} depth="zero">\\1</sem:#{@ab[:fn]}>}).
|
|
454
|
+
gsub(/;\{([^}]+(?![;]))\};mn?\b/m, %{<sem:#{@ab[:mn]} depth="zero">\\1</sem:#{@ab[:mn]}>}).
|
|
455
|
+
gsub(/;\{([^}]+(?![;]))\};ln?\b/m, %{<sem:#{@ab[:ln]} depth="zero">\\1</sem:#{@ab[:ln]}>}).
|
|
456
|
+
gsub(/;\{([^}]+(?![;]))\};in\b/m, %{<sem:#{@ab[:in]} depth="zero">\\1</sem:#{@ab[:in]}>}).
|
|
457
|
+
gsub(/;\{([^}]+(?![;]))\};uni\b/m, %{<sem:#{@ab[:uni]} depth="zero">\\1</sem:#{@ab[:uni]}>}).
|
|
458
|
+
gsub(/;\{([^}]+(?![;]))\};fac\b/m, %{<sem:#{@ab[:fac]} depth="zero">\\1</sem:#{@ab[:fac]}>}).
|
|
459
|
+
gsub(/;\{([^}]+(?![;]))\};inst\b/m, %{<sem:#{@ab[:inst]} depth="zero">\\1</sem:#{@ab[:inst]}>}).
|
|
460
|
+
gsub(/;\{([^}]+(?![;]))\};dept\b/m, %{<sem:#{@ab[:dpt]} depth="zero">\\1</sem:#{@ab[:dept]}>}).
|
|
461
|
+
gsub(/;\{([^}]+(?![;]))\};org\b/m, %{<sem:#{@ab[:org]} depth="zero">\\1</sem:#{@ab[:org]}>}).
|
|
462
|
+
gsub(/;\{([^}]+(?![;]))\};com?\b/m, %{<sem:#{@ab[:com]} depth="zero">\\1</sem:#{@ab[:com]}>}).
|
|
463
|
+
gsub(/;\{([^}]+(?![;]))\};cty\b/m, %{<sem:#{@ab[:cty]} depth="zero">\\1</sem:#{@ab[:cty]}>}).
|
|
464
|
+
gsub(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="zero">\1</sem:\2>')
|
|
465
|
+
end
|
|
466
|
+
dob
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
module SiSU_XML_Tags #Format
|
|
471
|
+
require_relative 'dp' # dp.rb
|
|
472
|
+
include SiSU_Param
|
|
473
|
+
class RDF
|
|
474
|
+
include SiSU_Parts_XML
|
|
475
|
+
def initialize(md='',seg_name=[],tracker=0)
|
|
476
|
+
@full_title=@subtitle=@author=@subject=@description=@publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@copyright=@owner=@keywords=''
|
|
477
|
+
@md=md
|
|
478
|
+
@rdfurl=%{ rdf:about="http://www.jus.uio.no/lm/toc"\n}
|
|
479
|
+
if defined? @md.title.full \
|
|
480
|
+
and @md.title.full # DublinCore 1 - title
|
|
481
|
+
@rdf_title=%{ dc.title="#{seg_name}#{@md.title.full}"\n}
|
|
482
|
+
@full_title=%{ <meta name="dc.title" content="#{@md.title.full}" />\n}
|
|
483
|
+
end
|
|
484
|
+
if defined? @md.creator.author \
|
|
485
|
+
and @md.creator.author=~/\S+/ # DublinCore 2 - creator/author (author)
|
|
486
|
+
@rdf_author=%{ dc.author="#{@md.creator.author}"\n}
|
|
487
|
+
content=meta_content_clean(@md.creator.author)
|
|
488
|
+
@author=%{ <meta name="dc.author" content="#{content}" />\n}
|
|
489
|
+
end
|
|
490
|
+
if defined? @md.publisher \
|
|
491
|
+
and @md.publisher # DublinCore 5 - publisher (current copy published by)
|
|
492
|
+
@rdf_publisher=%{ dc.publisher="#{@md.publisher}"\n}
|
|
493
|
+
content=meta_content_clean(@md.publisher)
|
|
494
|
+
@publisher=%{ <meta name="dc.publisher" content="#{content}" />\n}
|
|
495
|
+
end
|
|
496
|
+
if defined? @md.creator.contributor \
|
|
497
|
+
and @md.creator.contributor=~/\S+/ # DublinCore 6 - contributor
|
|
498
|
+
@rdf_contributor=%{ dc.contributor="#{@md.creator.contributor}"\n}
|
|
499
|
+
content=meta_content_clean(@md.creator.contributor)
|
|
500
|
+
@contributor=%{ <meta name="dc.contributor" content="#{content}" />\n}
|
|
501
|
+
end
|
|
502
|
+
if defined? @md.date.published \
|
|
503
|
+
and @md.date.published=~/\S+/ # DublinCore 7 - date year-mm-dd
|
|
504
|
+
@rdf_date=%{ dc.date="#{@md.date.published}"\n}
|
|
505
|
+
@date=%{ <meta name="dc.date" content="#{@md.date.published}" #{@md.date_scheme} />\n} # fix @md.date_scheme
|
|
506
|
+
end
|
|
507
|
+
if defined? @md.date.created \
|
|
508
|
+
and @md.date.created=~/\S+/ # DublinCore 7 - date.created year-mm-dd
|
|
509
|
+
@rdf_date_created=%{ dc.date.created="#{@md.date.created}"\n}
|
|
510
|
+
@date_created=%{ <meta name="dc.date.created" content="#{@md.date.created}" #{@md.date_scheme} />\n}
|
|
511
|
+
end
|
|
512
|
+
if defined? @md.date.issued \
|
|
513
|
+
and @md.date.issued=~/\S+/ # DublinCore 7 - date.issued year-mm-dd
|
|
514
|
+
@rdf_date_issued=%{ dc.date.issued="#{@md.date.issued}"\n}
|
|
515
|
+
@date_issued=%{ <meta name="dc.date.issued" content="#{@md.date.issued}" #{@md.date_scheme} />\n}
|
|
516
|
+
end
|
|
517
|
+
if defined? @md.date.available \
|
|
518
|
+
and @md.date.available=~/\S+/ # DublinCore 7 - date.available year-mm-dd
|
|
519
|
+
@rdf_date_available=%{ dc.date.available="#{@md.date.available}"\n}
|
|
520
|
+
@date_available=%{ <meta name="dc.date.available" content="#{@md.date.available}" #{@md.date_scheme} />\n}
|
|
521
|
+
end
|
|
522
|
+
if defined? @md.date.valid \
|
|
523
|
+
and @md.date.valid=~/\S+/ # DublinCore 7 - date.valid year-mm-dd
|
|
524
|
+
@rdf_date_valid=%{ dc.date.valid="#{@md.date.valid}"\n}
|
|
525
|
+
@date_valid=%{ <meta name="dc.date.valid" content="#{@md.date.valid}" #{@md.date_scheme} />\n}
|
|
526
|
+
end
|
|
527
|
+
if defined? @md.date.modified \
|
|
528
|
+
and @md.date.modified=~/\S+/ # DublinCore 7 - date.modified year-mm-dd
|
|
529
|
+
@rdf_date_modified=%{ dc.date.modified="#{@md.date.modified}"\n}
|
|
530
|
+
@date_modified=%{ <meta name="dc.date.modified" content="#{@md.date.modified}" #{@md.date_scheme} />\n}
|
|
531
|
+
end
|
|
532
|
+
if defined? @md.rights.all \
|
|
533
|
+
and @md.rights.all # DublinCore 15 - rights
|
|
534
|
+
@rdf_rights=%{ dc.rights="#{@md.rights.all}"\n}
|
|
535
|
+
content=meta_content_clean(@md.rights.all)
|
|
536
|
+
@rights=%{ <meta name="dc.rights" content="#{content}" />\n}
|
|
537
|
+
end
|
|
538
|
+
if defined? @md.classify.subject \
|
|
539
|
+
and @md.classify.subject=~/\S+/ # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
|
|
540
|
+
@rdf_subject=%{ dc.subject="#{@md.classify.subject}"\n}
|
|
541
|
+
content=meta_content_clean(@md.classify.subject)
|
|
542
|
+
@subject=%{ <meta name="dc.subject" content="#{content}" />\n}
|
|
543
|
+
end
|
|
544
|
+
if defined? @md.notes.description \
|
|
545
|
+
and @md.notes.description=~/\S+/ # DublinCore 4 - description
|
|
546
|
+
@rdf_description=%{ dc.description="#{@md.notes.description}"\n}
|
|
547
|
+
content=meta_content_clean(@md.notes.description)
|
|
548
|
+
@description=%{ <meta name="dc.description" content="#{content}" />\n}
|
|
549
|
+
end
|
|
550
|
+
if defined? @md.notes.coverage \
|
|
551
|
+
and @md.notes.coverage=~/\S+/ # DublinCore 14 - coverage
|
|
552
|
+
@rdf_coverage=%{ dc.coverage="#{@md.notes.coverage}"\n}
|
|
553
|
+
content=meta_content_clean(@md.notes.coverage)
|
|
554
|
+
@coverage=%{ <meta name="dc.coverage" content="#{content}" />\n}
|
|
555
|
+
end
|
|
556
|
+
if defined? @md.notes.relation \
|
|
557
|
+
and @md.notes.relation=~/\S+/ # DublinCore 13 - relation
|
|
558
|
+
@rdf_relation=%{ dc.relation="#{@md.notes.relation}"\n}
|
|
559
|
+
content=meta_content_clean(@md.notes.relation)
|
|
560
|
+
@relation=%{ <meta name="dc.relation" content="#{content}" />\n}
|
|
561
|
+
end
|
|
562
|
+
if defined? @md.notes.type \
|
|
563
|
+
and @md.notes.type # DublinCore 8 - type (genre eg. report, convention etc)
|
|
564
|
+
@rdf_type=%{ dc.type="#{@md.notes.type}"\n}
|
|
565
|
+
content=meta_content_clean(@md.notes.type)
|
|
566
|
+
@type=%{ <meta name="dc.type" content="#{content}" />\n}
|
|
567
|
+
end
|
|
568
|
+
if defined? @md.notes.format \
|
|
569
|
+
and @md.notes.format=~/\S+/ # DublinCore 9 - format (use your mime type)
|
|
570
|
+
@rdf_format=%{ dc.format="#{@md.notes.format}"\n}
|
|
571
|
+
content=meta_content_clean(@md.notes.format)
|
|
572
|
+
@format=%{ <meta name="dc.format" content="#{content}" />\n}
|
|
573
|
+
end
|
|
574
|
+
#if defined? @md.identifier.sisupod \
|
|
575
|
+
#and @md.identifier.sisupod=~/\S+/ # DublinCore 10 - identifier (your identifier, could use urn which is free)
|
|
576
|
+
# @rdf_identifier=%{ dc.identifier="#{@md.identifier.sisupod}"\n}
|
|
577
|
+
# content=meta_content_clean(@md.identifier.sisupod)
|
|
578
|
+
# @identifier=%{ <meta name="dc.identifier" content="#{content}" />\n}
|
|
579
|
+
#end
|
|
580
|
+
if defined? @md.original.source \
|
|
581
|
+
and @md.original.source=~/\S+/ # DublinCore 11 - source (document source)
|
|
582
|
+
@rdf_source=%{ dc.source="#{@md.original.source}"\n}
|
|
583
|
+
content=meta_content_clean(@md.original.source)
|
|
584
|
+
@source=%{ <meta name="dc.source" content="#{content}" />\n}
|
|
585
|
+
end
|
|
586
|
+
if defined? @md.title.language \
|
|
587
|
+
and @md.title.language=~/\S+/ # DublinCore 12 - language (English)
|
|
588
|
+
@rdf_language=%{ dc.language="#{@md.title.language}"\n}
|
|
589
|
+
@language=%{ <meta name="dc.language" content="#{@md.title.language}" />\n}
|
|
590
|
+
end
|
|
591
|
+
if defined? @md.original.language \
|
|
592
|
+
and @md.original.language=~/\S+/
|
|
593
|
+
@rdf_language_original=%{ dc.language="#{@md.original.language}"\n}
|
|
594
|
+
@language_original=%{ <meta name="dc.language" content="#{@md.original.language}" />\n}
|
|
595
|
+
end
|
|
596
|
+
content=meta_content_clean(@md.keywords)
|
|
597
|
+
@keywords=%{ <meta name="keywords" content="#{content}" />\n} if @md.keywords
|
|
598
|
+
end
|
|
599
|
+
def meta_content_clean(content='')
|
|
600
|
+
content=if not content.nil?
|
|
601
|
+
content=content.tr('"',"'").
|
|
602
|
+
gsub(/&/,'&')
|
|
603
|
+
content=SiSU_XML_Munge::Trans.new(@md).char_enc.utf8(content)
|
|
604
|
+
else content
|
|
605
|
+
end
|
|
606
|
+
end
|
|
607
|
+
def rdfseg #segHead
|
|
608
|
+
rdftoc
|
|
609
|
+
end
|
|
610
|
+
def comment_xml(extra='')
|
|
611
|
+
generator="Generated by: #{@md.project_details.project} #{@md.project_details.version} of #{@md.project_details.date_stamp} (#{@md.project_details.date})" if @md.project_details.version
|
|
612
|
+
lastdone="Last Generated on: #{Time.now}"
|
|
613
|
+
rubyv="Ruby version: #{@md.ruby_version}"
|
|
614
|
+
sc=if @md.sc_info
|
|
615
|
+
"Source file: #{@md.sc_filename} version: #{@md.sc_number} of: #{@md.sc_date}"
|
|
616
|
+
else ''
|
|
617
|
+
end
|
|
618
|
+
if extra.empty?
|
|
619
|
+
<<WOK
|
|
620
|
+
<!-- Document processing information:
|
|
621
|
+
* #{generator}
|
|
622
|
+
* #{rubyv}
|
|
623
|
+
* #{sc}
|
|
624
|
+
* #{lastdone}
|
|
625
|
+
* SiSU http://www.jus.uio.no/sisu
|
|
626
|
+
-->
|
|
627
|
+
WOK
|
|
628
|
+
else
|
|
629
|
+
<<WOK
|
|
630
|
+
<!-- Document processing information:
|
|
631
|
+
* #{extra}
|
|
632
|
+
* #{generator}
|
|
633
|
+
* #{rubyv}
|
|
634
|
+
* #{sc}
|
|
635
|
+
* #{lastdone}
|
|
636
|
+
* SiSU http://www.jus.uio.no/sisu
|
|
637
|
+
-->
|
|
638
|
+
WOK
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
def comment_xml_sax
|
|
642
|
+
desc='SiSU XML, SAX type representation'
|
|
643
|
+
comment_xml(desc)
|
|
644
|
+
end
|
|
645
|
+
def comment_xml_node
|
|
646
|
+
desc='SiSU XML, Node type representation'
|
|
647
|
+
comment_xml(desc)
|
|
648
|
+
end
|
|
649
|
+
def comment_xml_dom
|
|
650
|
+
desc='SiSU XML, DOM type representation'
|
|
651
|
+
comment_xml(desc)
|
|
652
|
+
end
|
|
653
|
+
def metatag_html #values strung together, because some empty, and resulting output (line breaks) is much better
|
|
654
|
+
<<WOK
|
|
655
|
+
#{@full_title}#{@subtitle}#{@author}#{@subject}#{@description}#{@publisher}#{@contributor}#{@date}#{@date_created}#{@date_issued}#{@date_available}#{@date_valid}#{@date_modified}#{@type}#{@format}#{@identifier}#{@source}#{@language}#{@relation}#{@coverage}#{@rights}#{@copyright}#{@owner}
|
|
656
|
+
#{SiSU_Proj_XML::Bits.new.txt_generator}
|
|
657
|
+
#{the_png.ico}
|
|
658
|
+
WOK
|
|
659
|
+
end
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
module SiSU_Tables
|
|
663
|
+
require_relative 'xml_tables' # xml_tables.rb
|
|
664
|
+
end
|
|
665
|
+
__END__
|