\Format pdf6 pdf "PDF (graphics)" "" "%%" "" "vector" "application/pdf"
\Format pdf7 pdf "PDF (cropped)" "" "%%" "" "document,vector" ""
\Format pdf8 pdf "PDF (lower resolution)" "" "%%" "" "document,vector" ""
-\Format pdf9 pdf "PDF (docbook)" "" "%%" "" "document,vector,menu=export" ""'''])
+\Format pdf9 pdf "PDF (docbook)" "" "%%" "" "document,vector,menu=export" ""'''])
#
checkViewer('a DVI previewer', ['xdvi', 'kdvi', 'okular',
'evince', 'xreader',
checkProg('an Open Document (Pandoc) -> LaTeX converter', ['pandoc -s -f odt -o $$o -t latex $$i'],
rc_entry = [ r'\converter odt3 latex "%%" ""' ])
#
- checkProg('DocBook converter -> PDF (docbook)', ['pandoc -f docbook -t latex --latex-engine=lualatex --toc -o $$o $$i'],
- rc_entry = [ r'\converter docbook5 pdf9 "%%" ""' ])
+ checkProg('DocBook converter -> PDF (docbook)', ['pandoc -f docbook -t latex --latex-engine=lualatex --toc --template=$$s/xtemplates/lyx.latex -o $$o $$i'],
+ rc_entry = [ r'\converter docbook5 pdf9 "%%" ""' ])
#
checkProg('a MS Word Office Open XML converter -> LaTeX', ['pandoc -s -f docx -o $$o -t latex $$i'],
rc_entry = [ r'\converter word2 latex "%%" ""' ])
\converter oocalc html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
\converter excel html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
\converter excel2 html_table "ssconvert --export-type=Gnumeric_html:html40frag $$i $$o" ""
+\converter gnumeric xhtml_table "python $$s/scripts/spreadsheet_to_docbook.py $$i $$o" ""
+\converter oocalc xhtml_table "python $$s/scripts/spreadsheet_to_docbook.py $$i $$o" ""
+\converter excel xhtml_table "python $$s/scripts/spreadsheet_to_docbook.py $$i $$o" ""
+\converter excel2 xhtml_table "python $$s/scripts/spreadsheet_to_docbook.py $$i $$o" ""
'''])
path, lilypond = checkProg('a LilyPond -> EPS/PDF/PNG converter', ['lilypond'])
--- /dev/null
+#!/usr/bin/python3
+
+# file spreadsheet_to_docbook.py
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+
+# author Thibaut Cuvelier & Kornel Benko
+
+# Full author contact details are available in file CREDITS.
+
+"""reformat output of ssconvert of a single spreadsheet to match the needs
+of docbook5 table format .
+
+Expects to read from file specified by sys.argv[1]
+and output to to file specified by sys.argv[2]
+"""
+
+import re
+import sys
+import subprocess
+
+
+def process_file(contents):
+ # Scrap the header and the footer.
+ contents = contents.split("<body>")[1]
+ contents = contents.split("</body>")[0]
+
+ # Gnumeric may generate more than one table, just take the first one.
+ contents = contents.split("</table>")[0] + "\n</table>"
+
+ # Convert the rest of the table to DocBook.
+ contents = contents.replace("<p></p>", "")
+ contents = contents.replace("<i>", "<emphasis>")
+ contents = contents.replace("</i>", "</emphasis>")
+ contents = contents.replace("<b>", "<emphasis role='bold'>")
+ contents = contents.replace("</b>", "</emphasis>")
+ contents = contents.replace("<u>", "<emphasis role='underline'>")
+ contents = contents.replace("</u>", "</emphasis>")
+
+ contents = re.sub(r"<font color=\"(.*)\">", "<phrase role='color \\1'>", contents)
+ assert '<font' not in contents # If this happens, implement something to catch these cases.
+ contents = contents.replace("</font>", "</phrase>") # Generates invalid XML if there are still font tags left...
+
+ # If the table has a caption, then the right tag is <table>. Otherwise, it's <informaltable>.
+ if '<caption>' not in contents:
+ contents = contents.replace("<table", "<informaltable")
+ contents = contents.replace("</table>", "</informaltable>")
+
+ # Return the processed string.
+ contents = contents.replace("\n\n", "\n")
+ return contents
+
+
+if __name__ == "__main__":
+ if len(sys.argv) == 1:
+ # Read from stdin, output to stdout.
+ contents = sys.stdin.read()
+ f = sys.stdout
+ else:
+ # Read from output of ssconvert
+ assert len(sys.argv) == 3 # Script name, file to process, output file.
+ proc = subprocess.Popen(["ssconvert", "--export-type=Gnumeric_html:xhtml", sys.argv[1], "fd://1"], stdout=subprocess.PIPE)
+ f = open(sys.argv[2], 'w')
+ sys.stdout = f # Redirect stdout to the output file.
+ contents = proc.stdout.read()
+
+ # Process and output to stdout.
+ print(process_file(contents))
+ f.close()
+ exit(0)