diff options
Diffstat (limited to 'lib/sisu/txt_orgmode.rb')
-rw-r--r-- | lib/sisu/txt_orgmode.rb | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/lib/sisu/txt_orgmode.rb b/lib/sisu/txt_orgmode.rb index 0771320d..93d65aaa 100644 --- a/lib/sisu/txt_orgmode.rb +++ b/lib/sisu/txt_orgmode.rb @@ -7,11 +7,11 @@ *** plaintext (smarttext) generation, orgmode structure ** Author: Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> + [ralph@amissah.com] + [ralph.amissah@gmail.com] ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Ralph Amissah, All Rights Reserved. ** License: GPL 3 or later: @@ -31,14 +31,12 @@ more details. You should have received a copy of the GNU General Public License along with - this program. If not, see <http://www.gnu.org/licenses/>. + this program. If not, see [http://www.gnu.org/licenses/]. If you have Internet connection, the latest version of the GPL should be available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + [http://www.fsf.org/licensing/licenses/gpl.html] + [http://www.gnu.org/licenses/gpl.html] ** SiSU uses: * Standard SiSU markup syntax, @@ -46,12 +44,12 @@ * Standard SiSU object citation numbering and system ** Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> + [http://www.jus.uio.no/sisu] + [http://www.sisudoc.org] ** Git - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/txt_orgmode.rb;hb=HEAD> + [http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary] + [http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/txt_orgmode.rb;hb=HEAD] =end module SiSU_Txt_OrgMode @@ -108,6 +106,19 @@ module SiSU_Txt_OrgMode else true end @plaintext={ body: [], open: [], close: [], head: [], endnotes: [], metadata: [], tail: [] } + @plaintext[:head]= <<-WOK +#+TITLE: #{@md.title.short} +#+AUTHOR: #{@md.creator.author} +#+EMAIL: #{@md.creator.email} +#+STARTUP: indent content +#+LANGUAGE: #{@md.opt.lng} +#+OPTIONS: H:3 num:nil toc:t \\n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t +#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc +#+OPTIONS: author:nil email:nil creator:nil timestamp:nil +#+EXPORT_SELECT_TAGS: export +#+EXPORT_EXCLUDE_TAGS: noexport + + WOK end def songsheet plaintext=markup(@data) @@ -117,7 +128,8 @@ module SiSU_Txt_OrgMode "\n" end def extract_endnotes(dob='') - notes=dob.obj.scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) + notes=dob.obj. + scan(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})([\d*+]+\s+.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/) @n=[] notes.flatten.each do |n| #high cost to deal with <br> appropriately within plaintext, consider n=n.dup.to_s @@ -138,7 +150,7 @@ module SiSU_Txt_OrgMode wrap=util.line_wrap wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m wrap.gsub(/^(\s*)([\d*+]+)\s+(.+?)\s*\Z/m, <<-GSUB -\\1[\\2]: \\3 +\\1[fn:\\2] \\3 GSUB ) else @@ -148,7 +160,7 @@ module SiSU_Txt_OrgMode ) end @@endnotes[:para] << "-#{wrap}" - @@endnotes[:end] << '' << wrap + @@endnotes[:end] << '' << wrap.strip end @@endnotes end @@ -283,13 +295,13 @@ WOK "#{decorate.monospace.open}\\1#{decorate.monospace.close}") unless dob.is==:code dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). - gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). - gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). - gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). - gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,"#{the_text.url_open}\\1#{the_text.url_close}") + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'[[\1]]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'[[\2][\1]]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'[[\1]] [link: local image]'). + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'[[\1]]') #urls extract_endnotes(dob) - dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[^\1]'). # endnote marker marked up - gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[^\1]'). # endnote marker marked up + dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'[fn:\1]'). # endnote marker marked up + gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'[fn:\1]'). # endnote marker marked up gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). @@ -312,7 +324,9 @@ WOK end if dob.is==:code dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< - gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< + gsub(/(^|[^}])_([<>])/m,'\1\2'). # _<_< + gsub(/^\*/m,',*') + dob.obj = '#+BEGIN_SRC sh :tangle no :padline no :exports none :noweb yes' + "\n" + dob.obj + '#+END_SRC' end dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). gsub(/<a href=".+?">(.+?)<\/a>/m,'\1'). |