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
data/lib/sisu/manpage.rb
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** manpage text generation, stripped manpage output (unix, linefeed)
|
|
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/manpage.rb;hb=HEAD>
|
|
55
|
+
|
|
56
|
+
=end
|
|
57
|
+
module SiSU_Manpage
|
|
58
|
+
require_relative 'ao' # ao.rb
|
|
59
|
+
require_relative 'se' # se.rb
|
|
60
|
+
include SiSU_Env
|
|
61
|
+
include SiSU_Param
|
|
62
|
+
require_relative 'manpage_format' # manpage_format.rb
|
|
63
|
+
include SiSU_ManpageFormat
|
|
64
|
+
require_relative 'shared_metadata' # shared_metadata.rb
|
|
65
|
+
require_relative 'generic_parts' # generic_parts.rb
|
|
66
|
+
require_relative 'txt_read' # txt_read.rb
|
|
67
|
+
require_relative 'txt_output' # txt_output.rb
|
|
68
|
+
require_relative 'txt_shared' # txt_shared.rb
|
|
69
|
+
@@alt_id_count,@@alt_id_count=0,0
|
|
70
|
+
@@tablefoot=''
|
|
71
|
+
class Source
|
|
72
|
+
include SiSU_Txt_Read
|
|
73
|
+
def initialize(opt)
|
|
74
|
+
@opt=opt
|
|
75
|
+
if @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
|
|
76
|
+
@@notes=:end
|
|
77
|
+
else
|
|
78
|
+
puts "#{sf} not a processed file type"
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
def read
|
|
82
|
+
begin
|
|
83
|
+
md=SiSU_Param::Parameters.new(@opt).get
|
|
84
|
+
specific={
|
|
85
|
+
description: 'Manpage',
|
|
86
|
+
output_path: md.file.output_path.manpage.dir,
|
|
87
|
+
output_file: md.file.base_filename.manpage,
|
|
88
|
+
}
|
|
89
|
+
read_generic(@opt,specific)
|
|
90
|
+
SiSU_Manpage::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
|
|
91
|
+
rescue
|
|
92
|
+
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
|
|
93
|
+
__LINE__.to_s + ':' + __FILE__
|
|
94
|
+
end
|
|
95
|
+
ensure
|
|
96
|
+
Dir.chdir(@opt.f_pth[:pth])
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
private
|
|
100
|
+
class Scroll <Source
|
|
101
|
+
include SiSU_Parts_Generic
|
|
102
|
+
include SiSU_TextUtils
|
|
103
|
+
@@endnotes={ para: [], end: [] }
|
|
104
|
+
def initialize(md,data,wrap_width)
|
|
105
|
+
@md,@data,@wrap_width=md,data,wrap_width
|
|
106
|
+
@tab="\t"
|
|
107
|
+
@@notes=:end
|
|
108
|
+
@manpage={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] }
|
|
109
|
+
end
|
|
110
|
+
def songsheet
|
|
111
|
+
manpage=markup(@data)
|
|
112
|
+
publish(manpage)
|
|
113
|
+
end
|
|
114
|
+
def break_line
|
|
115
|
+
"\n"
|
|
116
|
+
end
|
|
117
|
+
# Used for extraction of endnotes from paragraphs
|
|
118
|
+
def extract_endnotes(dob='')
|
|
119
|
+
para=dob.obj.gsub(/#{Mx[:br_line]}/,"\n")
|
|
120
|
+
notes=para.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+(?:\s|\n)+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m)
|
|
121
|
+
@n=[]
|
|
122
|
+
notes.flatten.each do |n| #high cost to deal with <br> appropriately within manpage, consider
|
|
123
|
+
n=n.dup.to_s
|
|
124
|
+
if n =~/#{Mx[:br_line]}|#{Mx[:br_nl]}/
|
|
125
|
+
fix = n.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/) #watch #added
|
|
126
|
+
fix.each do |x|
|
|
127
|
+
unless x.empty?; @n << x
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
else @n << n
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
notes=@n.flatten
|
|
134
|
+
notes.each do |e|
|
|
135
|
+
util=(e.to_s =~/^\[[\d*+]+\]:/) \
|
|
136
|
+
? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1))
|
|
137
|
+
: (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,0,1))
|
|
138
|
+
wrap=util.line_wrap
|
|
139
|
+
wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m
|
|
140
|
+
wrap.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires
|
|
141
|
+
gsub(/\s(.[BI])\s/,' ').
|
|
142
|
+
gsub(/\s\.(\S+)/,' \\.\1').
|
|
143
|
+
gsub(/^\s*([\d*+]+)\s+(.+?)\s*\Z/m, <<GSUB
|
|
144
|
+
.TP
|
|
145
|
+
.BI \\1.
|
|
146
|
+
\\2
|
|
147
|
+
GSUB
|
|
148
|
+
)
|
|
149
|
+
else
|
|
150
|
+
wrap.gsub(/^\s*(.+)\Z/m, <<GSUB
|
|
151
|
+
\\1
|
|
152
|
+
GSUB
|
|
153
|
+
)
|
|
154
|
+
end
|
|
155
|
+
@@endnotes[:para] << wrap
|
|
156
|
+
@@endnotes[:end] << wrap << "\n.BR"
|
|
157
|
+
@@endnotes
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
def manpage_metadata
|
|
161
|
+
@manpage[:metadata]=SiSU_Metadata::Summary.new(@md).manpage.metadata
|
|
162
|
+
end
|
|
163
|
+
def manpage_tail
|
|
164
|
+
@manpage[:tail] <<<<WOK
|
|
165
|
+
#{break_line}
|
|
166
|
+
.TP
|
|
167
|
+
.SH SEE ALSO
|
|
168
|
+
sisu(1),
|
|
169
|
+
sisu-epub(1),
|
|
170
|
+
sisu-harvest(1),
|
|
171
|
+
sisu-html(1),
|
|
172
|
+
sisu-odf(1),
|
|
173
|
+
sisu-pdf(1),
|
|
174
|
+
sisu-pg(1),
|
|
175
|
+
sisu-sqlite(1),
|
|
176
|
+
sisu-txt(1).
|
|
177
|
+
sisu_vim(7)
|
|
178
|
+
.TP
|
|
179
|
+
.SH HOMEPAGE
|
|
180
|
+
More information about SiSU can be found at <http://www.sisudoc.org/> or <http://www.jus.uio.no/sisu/>
|
|
181
|
+
.TP
|
|
182
|
+
.SH SOURCE
|
|
183
|
+
<http://git.sisudoc.org/>
|
|
184
|
+
.TP
|
|
185
|
+
.SH AUTHOR
|
|
186
|
+
SiSU is written by Ralph Amissah <ralph@amissah.com>
|
|
187
|
+
WOK
|
|
188
|
+
end
|
|
189
|
+
def manpage_structure(dob='',hname='') #% Used to extract the structure of a document
|
|
190
|
+
if dob.is==:heading
|
|
191
|
+
lv=dob.ln
|
|
192
|
+
dob.ln + 2
|
|
193
|
+
else lv=nil
|
|
194
|
+
end
|
|
195
|
+
wrapped=if dob.is==:para \
|
|
196
|
+
|| dob.is==:heading
|
|
197
|
+
paragraph=dob.obj
|
|
198
|
+
if dob.is==:para
|
|
199
|
+
if dob.indent =~/[1-9]/ \
|
|
200
|
+
and dob.indent == dob.hang
|
|
201
|
+
util=if dob.bullet_
|
|
202
|
+
SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,dob.indent.to_i*2)
|
|
203
|
+
else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2)
|
|
204
|
+
end
|
|
205
|
+
elsif dob.hang =~/[0-9]/ \
|
|
206
|
+
and dob.indent != dob.hang # NOT yet implemented
|
|
207
|
+
util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2)
|
|
208
|
+
else
|
|
209
|
+
util=if dob.bullet_
|
|
210
|
+
SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,0)
|
|
211
|
+
else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
else util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0)
|
|
215
|
+
end
|
|
216
|
+
w=util.line_wrap
|
|
217
|
+
w=w.gsub(/^(\\\.)/,' \1')
|
|
218
|
+
w
|
|
219
|
+
end
|
|
220
|
+
if lv
|
|
221
|
+
times=wrapped.length
|
|
222
|
+
times=@wrap_width if times > @wrap_width
|
|
223
|
+
@manpage[:body] << case lv
|
|
224
|
+
when 0 then '.SH ' << wrapped.upcase << break_line << break_line
|
|
225
|
+
when 1..3 then '.SH ' << wrapped.upcase << break_line << break_line
|
|
226
|
+
when 4 then '.SH ' << wrapped.upcase << break_line << break_line
|
|
227
|
+
when 5..6 then '.SH ' << wrapped.upcase << break_line << break_line
|
|
228
|
+
end
|
|
229
|
+
else
|
|
230
|
+
@manpage[:body] << if wrapped =~/^\.BI\s/ # main text, contents, body KEEP
|
|
231
|
+
'.TP' << break_line << wrapped.gsub(/(^\.B)I\s/,'\1 ') # sleight ... simpler output (check gsub!)
|
|
232
|
+
else
|
|
233
|
+
break_line + '.BR' + break_line << wrapped
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
if @@endnotes[:para] \
|
|
237
|
+
and @@notes==:foot #edit out to switch off endnotes following paragraph to which they belong
|
|
238
|
+
@@endnotes[:para].each { |e| @manpage[:body] << e << break_line }
|
|
239
|
+
elsif @@endnotes[:para] \
|
|
240
|
+
and @@notes==:end
|
|
241
|
+
end
|
|
242
|
+
@@endnotes[:para]=[]
|
|
243
|
+
end
|
|
244
|
+
def markup(data) # Used for major markup instructions
|
|
245
|
+
SiSU_Env::InfoEnv.new(@md.fns)
|
|
246
|
+
@data_mod,@endnotes,@level,@cont,@copen,@manpage_contents_close=Array.new(6){[]}
|
|
247
|
+
(0..6).each { |x| @cont[x]=@level[x]=false }
|
|
248
|
+
(4..6).each { |x| @manpage_contents_close[x]='' }
|
|
249
|
+
#manpage_tail # stop call
|
|
250
|
+
table_message='[table omitted, see other document formats]'
|
|
251
|
+
#manpage_metadata
|
|
252
|
+
data.each do |dob|
|
|
253
|
+
if dob.is==:comment \
|
|
254
|
+
|| dob.is==:heading_insert
|
|
255
|
+
dob.obj=''
|
|
256
|
+
end
|
|
257
|
+
dob.obj=dob.obj.gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check
|
|
258
|
+
gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^').
|
|
259
|
+
gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]').
|
|
260
|
+
gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'++\1++').
|
|
261
|
+
gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'--\1--').
|
|
262
|
+
gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"').
|
|
263
|
+
gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1').
|
|
264
|
+
gsub(/\A\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}#{Mx[:br_line]}([,.:!?](?: |$))?/m,
|
|
265
|
+
"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}").
|
|
266
|
+
gsub(/\s*#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}([,.:!?](?: |$))?/m,
|
|
267
|
+
"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}").
|
|
268
|
+
gsub(/\A\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?#{Mx[:br_line]}/m,
|
|
269
|
+
"\n.BI \\1\\2#{Mx[:br_line]}").
|
|
270
|
+
gsub(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?/m,
|
|
271
|
+
"#{Mx[:br_line]}.B \\1\\2#{Mx[:br_line]}").
|
|
272
|
+
gsub(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}([,.:!?](?: |$))?/,
|
|
273
|
+
"\n.I \\1\\2#{Mx[:br_line]}")
|
|
274
|
+
unless dob.is==:code
|
|
275
|
+
dob.obj=dob.obj.gsub(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,
|
|
276
|
+
"\\1 #{the_text.url_open}\\2#{the_text.url_close}\\3").
|
|
277
|
+
gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,
|
|
278
|
+
"\\1#{the_text.url_open}\\2#{the_text.url_close}\\3")
|
|
279
|
+
@manpage[:endnotes]=extract_endnotes(dob)
|
|
280
|
+
dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_a_c]}/m,'[^\1]'). # endnote marker marked up
|
|
281
|
+
gsub(/#{Mx[:en_b_o]}([\d*+]+)\s*(?:.+?)#{Mx[:en_b_c]}/m,'[^\1]'). # endnote marker marked up
|
|
282
|
+
gsub(/#{Mx[:gl_o]}#amp#{Mx[:gl_c]}/,'&'). ##{Mx[:gl_o]}#095#{Mx[:gl_c]}
|
|
283
|
+
gsub(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!').
|
|
284
|
+
gsub(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#').
|
|
285
|
+
gsub(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*').
|
|
286
|
+
gsub(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-').
|
|
287
|
+
gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\e').
|
|
288
|
+
gsub(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/').
|
|
289
|
+
gsub(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_').
|
|
290
|
+
gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
|
|
291
|
+
gsub(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}').
|
|
292
|
+
gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
|
|
293
|
+
gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©')
|
|
294
|
+
else
|
|
295
|
+
dob.obj=dob.obj.gsub(/\\/,'\e').
|
|
296
|
+
gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n") # watch
|
|
297
|
+
end
|
|
298
|
+
dob.obj=dob.obj.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires
|
|
299
|
+
gsub(/┆/,'|').
|
|
300
|
+
gsub(/^(\.\S{3,})/m,' \1') # ^\. used by interpreter, disable when use not intended
|
|
301
|
+
dob.obj=dob.obj.gsub(/~/,'~') if dob.obj #manpages use this
|
|
302
|
+
if dob.is ==:code
|
|
303
|
+
dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _<
|
|
304
|
+
gsub(/(^|[^}])_([<>])/m,'\1\2'). # _<_<
|
|
305
|
+
gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+(\s*)/m,"\n\\1"). # watch
|
|
306
|
+
gsub(/\A(.+?)\s*\Z/m,".nf\n\\1\n.fi")
|
|
307
|
+
end
|
|
308
|
+
dob.obj=dob.obj.gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})+\s*/m,"\n\n") # watch
|
|
309
|
+
dob.obj=dob.obj.gsub(/#{Mx[:gl_o]}:name#\S+?#{Mx[:gl_c]}/mi,''). #added
|
|
310
|
+
gsub(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}|#{Mx[:br_page_line]}/,''). # remove page breaks, you may wish to have a line across the page break instead
|
|
311
|
+
gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1\2').
|
|
312
|
+
gsub(/<a href=".+?">(.+?)<\/a>/m,'\1').
|
|
313
|
+
gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,''). # remove name links
|
|
314
|
+
gsub(/ |#{Mx[:nbsp]}/,' '). # decide on
|
|
315
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
|
|
316
|
+
gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]")
|
|
317
|
+
gsub(/^(?:^|[^_\\])#{Mx[:lnk_o]}\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*#{Mx[:lnk_c]}\S+/,'[image: "\1"]')
|
|
318
|
+
if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
|
|
319
|
+
if dob.obj =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change
|
|
320
|
+
paranum=dob.obj[@regx,3]
|
|
321
|
+
@p_num=SiSU_ManpageFormat::ParagraphNumber.new(paranum)
|
|
322
|
+
end
|
|
323
|
+
SiSU_ManpageFormat::FormatTextObject.new(@md,dob) #check
|
|
324
|
+
if dob.is==:heading
|
|
325
|
+
manpage_structure(dob)
|
|
326
|
+
elsif dob.is==:para
|
|
327
|
+
manpage_structure(dob)
|
|
328
|
+
else
|
|
329
|
+
if dob.obj =~/#{table_message}/
|
|
330
|
+
@manpage[:body] << dob.obj << break_line
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
if (dob.obj =~/<a name="n\d+">/ \
|
|
334
|
+
and dob.obj =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
|
|
335
|
+
dob.obj=''
|
|
336
|
+
end
|
|
337
|
+
if dob.obj
|
|
338
|
+
dob.obj=dob.obj.gsub(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*/,"\n\n"). # watch
|
|
339
|
+
gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~').
|
|
340
|
+
gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{').
|
|
341
|
+
gsub(/#{Mx[:pa_o]}\S+#{Mx[:pa_c]}/,' ')
|
|
342
|
+
unless dob.is ==:code
|
|
343
|
+
dob.obj=dob.obj.gsub(/<!.+!>/,' ').
|
|
344
|
+
gsub(/<:\S+>/,' ')
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
dob
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
@manpage
|
|
351
|
+
end
|
|
352
|
+
def publish(manpage)
|
|
353
|
+
content=[]
|
|
354
|
+
date=if defined? @md.date.modified \
|
|
355
|
+
and @md.date.modified
|
|
356
|
+
@md.date.modified
|
|
357
|
+
elsif defined? @md.date.published \
|
|
358
|
+
and @md.date.published
|
|
359
|
+
@md.date.published
|
|
360
|
+
else SiSU_Env::InfoDate.new.year #date missing decide on action
|
|
361
|
+
end
|
|
362
|
+
proj=SiSU_Env::InfoVersion.instance.get_version
|
|
363
|
+
manpage[:open] = %{.TH "#{@md.fnb}" "#{@md.make.manpage['section']}" "#{date}" "#{proj.version}" "#{@md.title.main}"#{@md.make.manpage['name']}#{@md.make.manpage['synopsis']}}
|
|
364
|
+
content << manpage[:open]
|
|
365
|
+
content << manpage[:head]
|
|
366
|
+
content << manpage[:body]
|
|
367
|
+
content << @@endnotes[:end] if @@notes==:end
|
|
368
|
+
content << manpage[:metadata]
|
|
369
|
+
content << manpage[:tail]
|
|
370
|
+
outputfile=SiSU_Env::FileOp.new(@md).write_file.manpage
|
|
371
|
+
Txt_Output::Output.new.document(content,outputfile)
|
|
372
|
+
@@endnotes={ para: [], end: [] }
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
__END__
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
=begin
|
|
3
|
+
|
|
4
|
+
* Name: SiSU
|
|
5
|
+
|
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
|
7
|
+
*** manpage formatting template
|
|
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/manpage_format.rb;hb=HEAD>
|
|
55
|
+
|
|
56
|
+
=end
|
|
57
|
+
module SiSU_ManpageFormat
|
|
58
|
+
require_relative 'dp' # dp.rb
|
|
59
|
+
include SiSU_Param
|
|
60
|
+
class ParagraphNumber
|
|
61
|
+
def initialize(paranum)
|
|
62
|
+
@paranum=/(\d+)/m.match(paranum)[1]
|
|
63
|
+
end
|
|
64
|
+
def display
|
|
65
|
+
@paranum.gsub(/(\d+)/,'<font size="1" color="#777777"> \1</font>')
|
|
66
|
+
end
|
|
67
|
+
def name
|
|
68
|
+
@paranum.gsub(/(\d+)/,'<a name="\1"></a>')
|
|
69
|
+
end
|
|
70
|
+
def goto
|
|
71
|
+
@paranum.gsub(/(\d+)/,'<a href="#\1">')
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
class FormatTextObject
|
|
75
|
+
def initialize(md,dob)
|
|
76
|
+
@md,@dob=md,dob
|
|
77
|
+
rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/
|
|
78
|
+
@dob.obj.gsub!(rgx,'\1') if @dob.obj =~rgx
|
|
79
|
+
end
|
|
80
|
+
def scr_endnote_body
|
|
81
|
+
"<endnote>#{@dob.obj}</endnote> "
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
__END__
|