sisu 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +7 -0
  2. data/bin/sisu +367 -0
  3. data/bin/sisugem +367 -0
  4. data/data/sisu/image/arrow_next_red.png +0 -0
  5. data/data/sisu/image/arrow_prev_red.png +0 -0
  6. data/data/sisu/image/arrow_up_red.png +0 -0
  7. data/data/sisu/image/b_bluebell.png +0 -0
  8. data/data/sisu/image/b_doc.png +0 -0
  9. data/data/sisu/image/b_epub.png +0 -0
  10. data/data/sisu/image/b_home.png +0 -0
  11. data/data/sisu/image/b_info.png +0 -0
  12. data/data/sisu/image/b_odf.png +0 -0
  13. data/data/sisu/image/b_pdf.png +0 -0
  14. data/data/sisu/image/b_search.png +0 -0
  15. data/data/sisu/image/b_toc.png +0 -0
  16. data/data/sisu/image/bullet_08.png +0 -0
  17. data/data/sisu/image/bullet_09.png +0 -0
  18. data/data/sisu/image/bullet_10.png +0 -0
  19. data/data/sisu/image/bullet_11.png +0 -0
  20. data/data/sisu/image/bullet_12.png +0 -0
  21. data/data/sisu/image/bullet_doc.png +0 -0
  22. data/data/sisu/image/bullet_red.png +0 -0
  23. data/data/sisu/image/dot_clear.png +0 -0
  24. data/data/sisu/image/dot_white.png +0 -0
  25. data/data/sisu/image/gplv3.png +0 -0
  26. data/data/sisu/image/gplv3_free_software.png +0 -0
  27. data/data/sisu/image/next.png +0 -0
  28. data/data/sisu/image/previous.png +0 -0
  29. data/data/sisu/image/rb7.ico +0 -0
  30. data/data/sisu/image/sisu.png +0 -0
  31. data/data/sisu/image/toctoc.png +0 -0
  32. data/data/sisu/version.yml +5 -0
  33. data/lib/sisu.rb +94 -0
  34. data/lib/sisu/air.rb +80 -0
  35. data/lib/sisu/ao.rb +590 -0
  36. data/lib/sisu/ao_character_check.rb +102 -0
  37. data/lib/sisu/ao_composite.rb +286 -0
  38. data/lib/sisu/ao_doc_objects.rb +565 -0
  39. data/lib/sisu/ao_doc_str.rb +2269 -0
  40. data/lib/sisu/ao_endnotes.rb +136 -0
  41. data/lib/sisu/ao_expand_insertions.rb +514 -0
  42. data/lib/sisu/ao_hash_digest.rb +174 -0
  43. data/lib/sisu/ao_idx.rb +422 -0
  44. data/lib/sisu/ao_images.rb +187 -0
  45. data/lib/sisu/ao_metadata.rb +86 -0
  46. data/lib/sisu/ao_misc_arrange.rb +207 -0
  47. data/lib/sisu/ao_numbering.rb +720 -0
  48. data/lib/sisu/ao_persist.rb +194 -0
  49. data/lib/sisu/ao_references.rb +502 -0
  50. data/lib/sisu/ao_syntax.rb +640 -0
  51. data/lib/sisu/cgi.rb +84 -0
  52. data/lib/sisu/cgi_pgsql.rb +270 -0
  53. data/lib/sisu/cgi_sql_common.rb +986 -0
  54. data/lib/sisu/cgi_sqlite.rb +244 -0
  55. data/lib/sisu/conf.rb +287 -0
  56. data/lib/sisu/constants.rb +388 -0
  57. data/lib/sisu/css.rb +3484 -0
  58. data/lib/sisu/db_columns.rb +1997 -0
  59. data/lib/sisu/db_create.rb +689 -0
  60. data/lib/sisu/db_dbi.rb +90 -0
  61. data/lib/sisu/db_drop.rb +207 -0
  62. data/lib/sisu/db_import.rb +877 -0
  63. data/lib/sisu/db_indexes.rb +146 -0
  64. data/lib/sisu/db_load_tuple.rb +323 -0
  65. data/lib/sisu/db_remove.rb +182 -0
  66. data/lib/sisu/db_select.rb +230 -0
  67. data/lib/sisu/db_sqltxt.rb +173 -0
  68. data/lib/sisu/db_tests.rb +114 -0
  69. data/lib/sisu/dbi.rb +166 -0
  70. data/lib/sisu/dbi_discrete.rb +206 -0
  71. data/lib/sisu/digests.rb +306 -0
  72. data/lib/sisu/dp.rb +1606 -0
  73. data/lib/sisu/dp_identify_markup.rb +161 -0
  74. data/lib/sisu/dp_make.rb +668 -0
  75. data/lib/sisu/embedded.rb +149 -0
  76. data/lib/sisu/errors.rb +84 -0
  77. data/lib/sisu/generic_parts.rb +131 -0
  78. data/lib/sisu/git.rb +277 -0
  79. data/lib/sisu/html.rb +775 -0
  80. data/lib/sisu/html_concordance.rb +391 -0
  81. data/lib/sisu/html_format.rb +1348 -0
  82. data/lib/sisu/html_harvest.rb +109 -0
  83. data/lib/sisu/html_harvest_author_format.rb +111 -0
  84. data/lib/sisu/html_harvest_authors.rb +466 -0
  85. data/lib/sisu/html_harvest_topics.rb +893 -0
  86. data/lib/sisu/html_lite_shared.rb +324 -0
  87. data/lib/sisu/html_manifest.rb +1032 -0
  88. data/lib/sisu/html_minitoc.rb +230 -0
  89. data/lib/sisu/html_parts.rb +437 -0
  90. data/lib/sisu/html_persist.rb +237 -0
  91. data/lib/sisu/html_promo.rb +440 -0
  92. data/lib/sisu/html_scroll.rb +235 -0
  93. data/lib/sisu/html_segments.rb +716 -0
  94. data/lib/sisu/html_shared.rb +62 -0
  95. data/lib/sisu/html_table.rb +64 -0
  96. data/lib/sisu/html_tune.rb +301 -0
  97. data/lib/sisu/hub.rb +277 -0
  98. data/lib/sisu/hub_actions.rb +1122 -0
  99. data/lib/sisu/hub_loop_markup_files.rb +170 -0
  100. data/lib/sisu/hub_options.rb +1695 -0
  101. data/lib/sisu/i18n.rb +702 -0
  102. data/lib/sisu/manpage.rb +377 -0
  103. data/lib/sisu/manpage_format.rb +85 -0
  104. data/lib/sisu/object_munge.rb +307 -0
  105. data/lib/sisu/prog_text_translation.rb +1702 -0
  106. data/lib/sisu/qrcode.rb +754 -0
  107. data/lib/sisu/relaxng.rb +1153 -0
  108. data/lib/sisu/remote.rb +246 -0
  109. data/lib/sisu/rexml.rb +148 -0
  110. data/lib/sisu/se.rb +158 -0
  111. data/lib/sisu/se_cleanoutput.rb +145 -0
  112. data/lib/sisu/se_clear.rb +105 -0
  113. data/lib/sisu/se_createsite.rb +273 -0
  114. data/lib/sisu/se_css.rb +221 -0
  115. data/lib/sisu/se_date.rb +92 -0
  116. data/lib/sisu/se_db.rb +214 -0
  117. data/lib/sisu/se_envcall.rb +326 -0
  118. data/lib/sisu/se_file_op.rb +2758 -0
  119. data/lib/sisu/se_filemap.rb +247 -0
  120. data/lib/sisu/se_get_init.rb +238 -0
  121. data/lib/sisu/se_hub_particulars.rb +234 -0
  122. data/lib/sisu/se_info_env.rb +2179 -0
  123. data/lib/sisu/se_info_port.rb +70 -0
  124. data/lib/sisu/se_info_system.rb +202 -0
  125. data/lib/sisu/se_load.rb +108 -0
  126. data/lib/sisu/se_processing.rb +659 -0
  127. data/lib/sisu/se_programs.rb +394 -0
  128. data/lib/sisu/se_remotes.rb +553 -0
  129. data/lib/sisu/se_standardise_lang.rb +176 -0
  130. data/lib/sisu/se_version.rb +174 -0
  131. data/lib/sisu/shared_images.rb +137 -0
  132. data/lib/sisu/shared_markup_alt.rb +336 -0
  133. data/lib/sisu/shared_metadata.rb +1361 -0
  134. data/lib/sisu/shared_sem.rb +156 -0
  135. data/lib/sisu/sisu_thor_lib.rb +407 -0
  136. data/lib/sisu/sitemaps.rb +224 -0
  137. data/lib/sisu/src_kdissert_share.rb +102 -0
  138. data/lib/sisu/src_po4a_share.rb +309 -0
  139. data/lib/sisu/src_po4a_shelf.rb +1217 -0
  140. data/lib/sisu/src_po4a_shelf_set.rb +297 -0
  141. data/lib/sisu/src_po4a_sst_ao_sst.rb +893 -0
  142. data/lib/sisu/src_po4a_sst_ao_sst_set.rb +284 -0
  143. data/lib/sisu/src_po4a_sstm.rb +135 -0
  144. data/lib/sisu/src_shared.rb +347 -0
  145. data/lib/sisu/src_sisupod_make.rb +171 -0
  146. data/lib/sisu/src_sisupod_sstm.rb +109 -0
  147. data/lib/sisu/sst_convert_markup.rb +323 -0
  148. data/lib/sisu/sst_do_inline_footnotes.rb +440 -0
  149. data/lib/sisu/sst_from_xml.rb +178 -0
  150. data/lib/sisu/sst_identify_markup.rb +482 -0
  151. data/lib/sisu/sst_to_s_xml_sax.rb +471 -0
  152. data/lib/sisu/termsheet.rb +163 -0
  153. data/lib/sisu/texinfo.rb +430 -0
  154. data/lib/sisu/texinfo_format.rb +541 -0
  155. data/lib/sisu/texpdf.rb +1162 -0
  156. data/lib/sisu/texpdf_format.rb +1689 -0
  157. data/lib/sisu/texpdf_parts.rb +235 -0
  158. data/lib/sisu/txt_asciidoc.rb +354 -0
  159. data/lib/sisu/txt_asciidoc_decorate.rb +207 -0
  160. data/lib/sisu/txt_markdown.rb +389 -0
  161. data/lib/sisu/txt_markdown_decorate.rb +207 -0
  162. data/lib/sisu/txt_orgmode.rb +376 -0
  163. data/lib/sisu/txt_orgmode_decorate.rb +186 -0
  164. data/lib/sisu/txt_output.rb +86 -0
  165. data/lib/sisu/txt_plain.rb +410 -0
  166. data/lib/sisu/txt_plain_decorate.rb +189 -0
  167. data/lib/sisu/txt_read.rb +109 -0
  168. data/lib/sisu/txt_rst.rb +371 -0
  169. data/lib/sisu/txt_rst_decorate.rb +186 -0
  170. data/lib/sisu/txt_shared.rb +241 -0
  171. data/lib/sisu/txt_textile.rb +367 -0
  172. data/lib/sisu/txt_textile_decorate.rb +186 -0
  173. data/lib/sisu/update.rb +141 -0
  174. data/lib/sisu/urls.rb +696 -0
  175. data/lib/sisu/utils.rb +232 -0
  176. data/lib/sisu/utils_composite.rb +115 -0
  177. data/lib/sisu/utils_response.rb +114 -0
  178. data/lib/sisu/utils_screen_text_color.rb +472 -0
  179. data/lib/sisu/utils_spell.rb +99 -0
  180. data/lib/sisu/webrick.rb +191 -0
  181. data/lib/sisu/wikispeak.rb +375 -0
  182. data/lib/sisu/xhtml.rb +472 -0
  183. data/lib/sisu/xhtml_epub2.rb +890 -0
  184. data/lib/sisu/xhtml_epub2_concordance.rb +322 -0
  185. data/lib/sisu/xhtml_epub2_format.rb +2272 -0
  186. data/lib/sisu/xhtml_epub2_persist.rb +278 -0
  187. data/lib/sisu/xhtml_epub2_segments.rb +599 -0
  188. data/lib/sisu/xhtml_epub2_tune.rb +330 -0
  189. data/lib/sisu/xhtml_parts.rb +183 -0
  190. data/lib/sisu/xhtml_shared.rb +62 -0
  191. data/lib/sisu/xhtml_table.rb +97 -0
  192. data/lib/sisu/xml_docbook5.rb +376 -0
  193. data/lib/sisu/xml_dom.rb +624 -0
  194. data/lib/sisu/xml_fictionbook2.rb +389 -0
  195. data/lib/sisu/xml_format.rb +865 -0
  196. data/lib/sisu/xml_md_oai_pmh_dc.rb +229 -0
  197. data/lib/sisu/xml_odf_odt.rb +887 -0
  198. data/lib/sisu/xml_odf_odt_format.rb +674 -0
  199. data/lib/sisu/xml_parts.rb +191 -0
  200. data/lib/sisu/xml_persist.rb +126 -0
  201. data/lib/sisu/xml_sax.rb +521 -0
  202. data/lib/sisu/xml_scaffold_structure_collapsed.rb +198 -0
  203. data/lib/sisu/xml_scaffold_structure_sisu.rb +201 -0
  204. data/lib/sisu/xml_shared.rb +665 -0
  205. data/lib/sisu/xml_tables.rb +261 -0
  206. data/lib/sisu/zap.rb +90 -0
  207. metadata +251 -0
@@ -0,0 +1,194 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** document abstraction
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/ao_persist.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_AO_Persist
58
+ class Persist
59
+ @@persistance=nil
60
+ attr_accessor :fns, :ao_arr, :idx_arr_sst, :idx_arr_tex, :idx_arr_html, :idx_arr_xhtml, :map_arr_nametags, :map_arr_ocn_htmlseg
61
+ def initialize(args=nil)
62
+ @@persistance=args=(args ? args : (@@persistance || persist_init_hash_values))
63
+ @fns=args[:fns]
64
+ @ao_arr=args[:ao_arr]
65
+ @idx_arr_sst=args[:idx_arr_sst]
66
+ @idx_arr_tex=args[:idx_arr_tex]
67
+ @idx_arr_html=args[:idx_arr_html]
68
+ @idx_arr_xhtml=args[:idx_arr_xhtml]
69
+ @map_arr_nametags=args[:map_arr_nametags]
70
+ @map_arr_ocn_htmlseg=args[:map_arr_ocn_htmlseg]
71
+ end
72
+ def fns
73
+ @fns
74
+ end
75
+ def ao_arr
76
+ @ao_arr
77
+ end
78
+ def idx_arr_sst
79
+ @idx_arr_sst
80
+ end
81
+ def idx_arr_tex
82
+ @idx_arr_tex
83
+ end
84
+ def idx_arr_html
85
+ @idx_arr_html
86
+ end
87
+ def idx_arr_xhtml
88
+ @idx_arr_xhtml
89
+ end
90
+ def map_arr_nametags
91
+ @map_arr_nametags
92
+ end
93
+ def map_arr_ocn_htmlseg
94
+ @map_arr_ocn_htmlseg
95
+ end
96
+ def persist_init_hash_values
97
+ {
98
+ fns: nil,
99
+ ao_arr: [],
100
+ idx_arr_sst: [],
101
+ idx_arr_tex: [],
102
+ idx_arr_html: [],
103
+ idx_arr_xhtml: [],
104
+ map_arr_nametags: [],
105
+ map_arr_ocn_htmlseg: [],
106
+ }
107
+ end
108
+ def persist_init
109
+ @@persistance=nil
110
+ Persist.new(persist_init_hash_values)
111
+ end
112
+ end
113
+ class PersistDocStructExt
114
+ @@persist=nil
115
+ attr_accessor :ocn, :lng, :lng_is, :code, :lngsyn, :poem, :block, :box, :group, :alt, :quote, :table, :table_to
116
+ def initialize(args=nil)
117
+ @@persist=args=(args ? args : (@@persist || persist_init_hash_values))
118
+ @ocn=args[:ocn]
119
+ @lng=args[:lng]
120
+ @lng_is=args[:lng_is]
121
+ @code=args[:code]
122
+ @lngsyn=args[:lngsyn]
123
+ @poem=args[:poem]
124
+ @block=args[:block]
125
+ @box=args[:box]
126
+ @group=args[:group]
127
+ @alt=args[:alt]
128
+ @quote=args[:quote]
129
+ @table=args[:table]
130
+ @table_to=args[:table_to]
131
+ end
132
+ def ocn
133
+ @ocn
134
+ end
135
+ def lng
136
+ @lng
137
+ end
138
+ def lng_is
139
+ @lng_is
140
+ end
141
+ def code
142
+ @code
143
+ end
144
+ def lngsyn
145
+ @lngsyn
146
+ end
147
+ def poem
148
+ @poem
149
+ end
150
+ def block
151
+ @block
152
+ end
153
+ def box
154
+ @box
155
+ end
156
+ def group
157
+ @group
158
+ end
159
+ def alt
160
+ @alt
161
+ end
162
+ def quote
163
+ @quote
164
+ end
165
+ def table
166
+ @table
167
+ end
168
+ def table_to
169
+ @table_to
170
+ end
171
+ def persist_init_hash_values
172
+ {
173
+ ocn: :on,
174
+ lng: :off,
175
+ lng_is: :doc_default,
176
+ code: :off,
177
+ lngsyn: :txt,
178
+ poem: :off,
179
+ block: :off,
180
+ box: :off,
181
+ group: :off,
182
+ alt: :off,
183
+ quote: :off,
184
+ table: :off,
185
+ table_to: :off,
186
+ }
187
+ end
188
+ def persist_init
189
+ @@persist=nil
190
+ PersistDocStructExt.new(persist_init_hash_values)
191
+ end
192
+ end
193
+ end
194
+ __END__
@@ -0,0 +1,502 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** system environment, resource control and configuration details
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/ao_references.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_AO_References
58
+ class Bibliography
59
+ def initialize(md,data)
60
+ @md,@data=md,data
61
+ end
62
+ def sort_bibliography_array_by_author_year_title(bib)
63
+ if bib
64
+ bib.compact.sort_by do |c|
65
+ [c[:author_arr][0],c[:year],c[:title]]
66
+ end
67
+ end
68
+ end
69
+ def citation_in_prepared_bibliography(cite)
70
+ @cite=cite
71
+ def article
72
+ {
73
+ is: :article,
74
+ author_raw: nil,
75
+ author: nil,
76
+ author_arr: nil,
77
+ title: nil,
78
+ language: nil,
79
+ journal: nil,
80
+ volume: nil,
81
+ editor: nil,
82
+ year: nil,
83
+ where: nil,
84
+ url: nil,
85
+ note: nil,
86
+ short_name: nil,
87
+ id: nil,
88
+ }
89
+ end
90
+ def book
91
+ {
92
+ is: :book,
93
+ author_raw: nil,
94
+ author: nil,
95
+ author_arr: nil,
96
+ #editor: nil,
97
+ title: nil,
98
+ subtitle: nil,
99
+ fulltitle: nil,
100
+ language: nil,
101
+ publisher: nil,
102
+ edition: nil,
103
+ year: nil,
104
+ where: nil,
105
+ url: nil,
106
+ note: nil,
107
+ short_name: nil,
108
+ id: nil,
109
+ }
110
+ end
111
+ def citation_metadata
112
+ type=if @cite =~/^jo: \S+/m
113
+ :article
114
+ elsif @cite =~/^au: \S+/m
115
+ :book
116
+ end
117
+ if type
118
+ citeblock=@cite.split("\n")
119
+ if type == :article
120
+ citation=article
121
+ citeblock.select do |meta|
122
+ case meta
123
+ when /^((?:au|author):\s+)\S+/ #req
124
+ citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1]
125
+ when /^((?:ti|title):\s+)\S+/ #req
126
+ citation[:title]=/^#{$1}(.+)/.match(meta)[1]
127
+ when /^((?:lng|language):\s+)\S+/
128
+ citation[:language]=/^#{$1}(.+)/.match(meta)[1]
129
+ when /^((?:jo|journal):\s+)\S+/ #req?
130
+ citation[:journal]=/^#{$1}(.+)/.match(meta)[1]
131
+ when /^((?:vo|volume):\s+)\S+/
132
+ citation[:volume]=/^#{$1}(.+)/.match(meta)[1]
133
+ when /^((?:edr|editor):\s+)\S+/
134
+ citation[:editor]=/^#{$1}(.+)/.match(meta)[1]
135
+ when /^((?:yr|year):\s+)\S+/ #req?
136
+ citation[:year]=/^#{$1}(.+)/.match(meta)[1]
137
+ when /^((?:pst|publisher_state):\s+)\S+/
138
+ citation[:where]=/^#{$1}(.+)/.match(meta)[1]
139
+ when /^(url:\s+)\S+/
140
+ citation[:url]=/^#{$1}(.+)/.match(meta)[1]
141
+ when /^(note:\s+)\S+/
142
+ citation[:note]=/^#{$1}(.+)/.match(meta)[1]
143
+ when /^((?:sn|shortname):\s+)\S+/
144
+ citation[:short_name]=/^#{$1}(.+)/.match(meta)[1]
145
+ when /^(id:\s+)\S+/
146
+ citation[:id]=/^#{$1}(.+)/.match(meta)[1]
147
+ end
148
+ end
149
+ end
150
+ if type == :book
151
+ citation=book
152
+ citeblock.select do |meta|
153
+ case meta
154
+ when /^((?:au|author):\s+)\S+/ #req
155
+ citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1]
156
+ when /^((?:ti|title):\s+)\S+/ #req
157
+ citation[:title]=/^#{$1}(.+)/.match(meta)[1]
158
+ when /^((?:st|subtitle):\s+)\S+/
159
+ citation[:subtitle]=/^#{$1}(.+)/.match(meta)[1]
160
+ when /^((?:lng|language):\s+)\S+/
161
+ citation[:language]=/^#{$1}(.+)/.match(meta)[1]
162
+ when /^((?:pb|publisher):\s+)\S+/
163
+ citation[:publisher]=/^#{$1}(.+)/.match(meta)[1]
164
+ when /^((?:edn|edition):\s+)\S+/
165
+ citation[:edition]=/^#{$1}(.+)/.match(meta)[1]
166
+ when /^((?:yr|year):\s+)\S+/ #req?
167
+ citation[:year]=/^#{$1}(.+)/.match(meta)[1]
168
+ when /^((?:pst|publisher_state):\s+)\S+/
169
+ citation[:where]=/^#{$1}(.+)/.match(meta)[1]
170
+ when /^(url:\s+)\S+/
171
+ citation[:url]=/^#{$1}(.+)/.match(meta)[1]
172
+ when /^(note:\s+)\S+/
173
+ citation[:note]=/^#{$1}(.+)/.match(meta)[1]
174
+ when /^((?:sn|shortname):\s+)\S+/
175
+ citation[:short_name]=/^#{$1}(.+)/.match(meta)[1]
176
+ when /^(id:\s+)\S+/
177
+ citation[:id]=/^#{$1}(.+)/.match(meta)[1]
178
+ end
179
+ end
180
+ end
181
+ if citation[:is]==:book
182
+ if citation[:subtitle]
183
+ citation[:fulltitle] = citation[:title] \
184
+ + ' - ' \
185
+ + citation[:subtitle]
186
+ else
187
+ citation[:fulltitle] = citation[:title]
188
+ end
189
+ end
190
+ citation[:author_arr]=citation[:author_raw].split(/;\s*/)
191
+ citation[:author]=citation[:author_arr].map do |author|
192
+ author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip
193
+ end.join(', ').strip
194
+ unless citation[:short_name]
195
+ citation[:short_name]=%{#{c[:author]}, "#{c[:short_name]}" (#{c[:date]})}
196
+ end
197
+ end
198
+ citation
199
+ end
200
+ self
201
+ end
202
+ def biblio_extraction
203
+ bibliography=[]
204
+ biblioflag=false
205
+ code_flag=false
206
+ flag_code_curly=:not_code_curly
207
+ flag_code_tics=:not_code_tics
208
+ @data=@data.select do |t_o|
209
+ if t_o =~/^code\{/
210
+ flag_code_curly=:code_curly
211
+ elsif t_o =~/^\}code/
212
+ flag_code_curly=:not_code_curly
213
+ elsif t_o =~/^``` code/
214
+ flag_code_tics=:code_tics
215
+ elsif flag_code_tics ==:code_tics \
216
+ and t_o =~/^```/
217
+ flag_code_tics=:not_code_tics
218
+ end
219
+ code_flag=if flag_code_curly==:code_curly \
220
+ or flag_code_tics==:code_tics
221
+ true
222
+ else false
223
+ end
224
+ unless code_flag
225
+ if @md.flag_auto_biblio
226
+ if t_o =~/^1~biblio(?:graphy)?/
227
+ biblioflag = true
228
+ t_o
229
+ elsif t_o =~/^:?[B-D1]~/
230
+ biblioflag = false
231
+ t_o
232
+ elsif biblioflag
233
+ if t_o !~/\A%+ /
234
+ bibliography << citation_in_prepared_bibliography(t_o).citation_metadata
235
+ next
236
+ else
237
+ t_o
238
+ end
239
+ else t_o
240
+ end
241
+ elsif @md.flag_biblio
242
+ if t_o =~/^1~biblio(?:graphy)?/
243
+ biblioflag = true
244
+ next
245
+ elsif t_o =~/^:?[B-D]~/
246
+ next
247
+ elsif t_o =~/^:?[B-D1]~/
248
+ biblioflag = false
249
+ t_o
250
+ elsif biblioflag
251
+ if t_o !~/\A%+ /
252
+ bibliography << t_o
253
+ next
254
+ else
255
+ t_o
256
+ end
257
+ else t_o
258
+ end
259
+ else t_o
260
+ end
261
+ else t_o
262
+ end
263
+ end.compact
264
+ if @md.flag_auto_biblio \
265
+ and bibliography.length > 0
266
+ data_new=[]
267
+ bibliography=sort_bibliography_array_by_author_year_title(bibliography)
268
+ @data.select do |t_o|
269
+ if t_o =~/^1~biblio(?:graphy)?/
270
+ bibliography.each do |c|
271
+ if c[:is]==:book
272
+ <<-WOK
273
+
274
+ !_ #{c[:author]}
275
+ /{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]})
276
+ WOK
277
+ elsif c[:is]==:article
278
+ <<-WOK
279
+
280
+ !_ #{c[:author]}
281
+ /{"#{c[:title]}"}/ #{c[:journal]} (#{c[:year]})
282
+ WOK
283
+ end
284
+ end
285
+ else data_new << t_o
286
+ end
287
+ end
288
+ @data=data_new
289
+ end
290
+ [@data,bibliography]
291
+ end
292
+ end
293
+ class Citations
294
+ def initialize(md='',data='')
295
+ @md,@data=md,data
296
+ #@biblio=[]
297
+ end
298
+ def songsheet
299
+ tuned_file,citations=citations_scan(@data)
300
+ [tuned_file,citations]
301
+ end
302
+ def sort_bibliography_array_by_author_year(bib)
303
+ bib.sort_by do |c|
304
+ [c[:author_raw],c[:year]]
305
+ #[c[:author_arr][0],c[:year],c[:title]]
306
+ end
307
+ end
308
+ def citations_regex
309
+ def pages_pattern
310
+ %r{(?:[,.:]?\s+(?:p{1,2}\.?\s+)?(?:\d+--?\d+)[,.]?\s+)?}
311
+ end
312
+ def editor_pattern
313
+ %r{(?<editor>(?:editor|edited by)\s+.+?)}
314
+ end
315
+ def year_pattern
316
+ %r{[(\[]?(?<year>\d{4})[\])]?[.,]?}
317
+ end
318
+ def authors_year_title_publication_editor_pages
319
+ /(?<authors>.+?)\s+#{year_pattern}\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor
320
+ end
321
+ def authors_title_publication_year_editor_pages
322
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor
323
+ end
324
+ def authors_title_publication_editor_year_pages ###
325
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+ed.\s+#{editor_pattern}#{year_pattern}#{pages_pattern}/m
326
+ # note ed. is usually edition rather than editor
327
+ end
328
+ def authors_title_publication_editor_pages_year ###
329
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}#{year_pattern}/m # note ed. is usually edition rather than editor
330
+ end
331
+ def authors_year_title_publication_pages
332
+ /(?<authors>.+?)\s+#{year_pattern}\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?#{pages_pattern}/m
333
+ end
334
+ def authors_title_publication_year_pages
335
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{pages_pattern}/m
336
+ end
337
+ def authors_title_publication_pages_year ###
338
+ /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}#{year_pattern}/m
339
+ end
340
+ def authors_year_publication_pages
341
+ /(?<authors>.+?)\s+#{year_pattern}\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}/m
342
+ end
343
+ def authors_publication_year_pages
344
+ /(?<authors>.+?)\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?\s+(?<publisher>.+?)?#{year_pattern}#{pages_pattern}[.;]?/m
345
+ end
346
+ self
347
+ end
348
+ def authors?(citations)
349
+ citations.each.map do |b|
350
+ if b =~ /^.+\s+::.+?:$/
351
+ c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b)
352
+ {
353
+ citation: c[:citation],
354
+ shortref: c[:shortref],
355
+ c[:shortref].to_s => c[:citation]
356
+ }
357
+ else { citation: b }
358
+ end
359
+ end
360
+ end
361
+ def long_and_short_ref?(citations) #could be useful, keep ... ectract shortref
362
+ citations.each.map do |b|
363
+ if b =~ /^.+\s+::.+?:$/
364
+ c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b)
365
+ {
366
+ citation: c[:citation],
367
+ shortref: c[:shortref],
368
+ c[:shortref].to_s => c[:citation]
369
+ }
370
+ else { citation: b }
371
+ end
372
+ end
373
+ end
374
+ def citation_detail(citations) #could be useful, keep ... extract shortref
375
+ bibahash=[]
376
+ number=0
377
+ missed=0
378
+ citations.select do |b|
379
+ z=if b =~citations_regex.authors_year_title_publication_editor_pages
380
+ c=citations_regex.authors_year_title_publication_editor_pages.match(b)
381
+ {
382
+ is: :article,
383
+ author_raw: c[:authors],
384
+ year: c[:year],
385
+ title: c[:title],
386
+ publication: c[:publication],
387
+ editor: c[:editor],
388
+ }
389
+ elsif b =~citations_regex.authors_title_publication_year_editor_pages
390
+ c=citations_regex.authors_title_publication_year_editor_pages.match(b)
391
+ {
392
+ is: :article,
393
+ author_raw: c[:authors],
394
+ year: c[:year],
395
+ title: c[:title],
396
+ publication: c[:publication],
397
+ editor: c[:editor],
398
+ }
399
+ elsif b =~citations_regex.authors_title_publication_editor_year_pages
400
+ c=citations_regex.authors_title_publication_editor_year_pages.match(b)
401
+ {
402
+ is: :article,
403
+ author_raw: c[:authors],
404
+ year: c[:year],
405
+ title: c[:title],
406
+ publication: c[:publication],
407
+ editor: c[:editor],
408
+ }
409
+ elsif b =~citations_regex.authors_title_publication_editor_pages_year
410
+ c=citations_regex.authors_title_publication_editor_pages_year.match(b)
411
+ {
412
+ is: :article,
413
+ author_raw: c[:authors],
414
+ year: c[:year],
415
+ title: c[:title],
416
+ publication: c[:publication],
417
+ editor: c[:editor],
418
+ }
419
+ elsif b =~citations_regex.authors_year_title_publication_pages
420
+ c=citations_regex.authors_year_title_publication_pages.match(b)
421
+ {
422
+ is: :article,
423
+ author_raw: c[:authors],
424
+ year: c[:year],
425
+ title: c[:title],
426
+ publication: c[:publication],
427
+ }
428
+ elsif b =~citations_regex.authors_title_publication_year_pages
429
+ c=citations_regex.authors_title_publication_year_pages.match(b)
430
+ {
431
+ is: :article,
432
+ author_raw: c[:authors],
433
+ year: c[:year],
434
+ title: c[:title],
435
+ publication: c[:publication],
436
+ }
437
+ elsif b =~citations_regex.authors_year_publication_pages
438
+ c=citations_regex.authors_year_publication_pages.match(b)
439
+ {
440
+ is: :book,
441
+ author_raw: c[:authors],
442
+ year: c[:year],
443
+ publication: c[:publication],
444
+ }
445
+ elsif b =~citations_regex.authors_publication_year_pages
446
+ c=citations_regex.authors_publication_year_pages.match(b)
447
+ {
448
+ is: :book,
449
+ author_raw: c[:authors],
450
+ year: c[:year],
451
+ publication: c[:publication],
452
+ }
453
+ else b
454
+ end
455
+ if not z.is_a?(NilClass) \
456
+ and z.is_a?(Hash) \
457
+ and z[:author_raw].length > 0
458
+ z[:author_arr]=z[:author_raw].split(/;\s*/)
459
+ z[:author]=z[:author_arr].map do |author|
460
+ author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip
461
+ end.join(', ').strip
462
+ if @md.opt.act[:verbose_plus][:set]==:on \
463
+ || @md.opt.act[:maintenance][:set]==:on
464
+ number +=1 if z.is_a?(Hash)
465
+ missed +=1 if z.is_a?(String)
466
+ (z.is_a?(Hash)) \
467
+ ? (p '[' + number.to_s + '] ' + z.to_s)
468
+ : (p '<' + missed.to_s + '> ' + z.to_s)
469
+ end
470
+ end
471
+ bibahash << z if z.is_a?(Hash)
472
+ end
473
+ bibahash=sort_bibliography_array_by_author_year(bibahash.compact)
474
+ bibahash
475
+ end
476
+ def citations_scan(data)
477
+ citations=[]
478
+ #short_ref=[]
479
+ tuned_file = data.compact.select do |dob|
480
+ if dob.is !=:meta \
481
+ && dob.is !=:comment \
482
+ && dob.is !=:code \
483
+ && dob.is !=:table
484
+ if dob.obj =~/\.:.+?:\./
485
+ citations << dob.obj.scan(/\.:\s*(.+?)\s*:\./m)
486
+ #short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::([^:]+)::\./m) #look at later
487
+ ##short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::(.+?)::\./m) #look at later
488
+ #short_ref << dob.obj.scan(/\.:\s*(.+?)\s*(::(.+?):)?:\./m) #look at later
489
+ citations=citations.flatten.compact
490
+ dob.obj=dob.obj. #remove citations delimiter & helpers from text
491
+ gsub(/\.:|:\./,'')
492
+ end
493
+ end
494
+ dob if dob.is_a?(Object)
495
+ end
496
+ #bib=long_and_short_ref?(citations) #could be useful, keep ... extract shortref
497
+ citations=citation_detail(citations)
498
+ [tuned_file,citations]
499
+ end
500
+ end
501
+ end
502
+ __END__