#! /usr/bin/python #~ import pandoc from pandoc import * def main (): newDocument('title\nof the document', ['author1', 'author2'], '25 june\n2017') addTOC() newPage() header ('Test quote Block', 1, '#header1') quoteBlock (['text 1', ['text 2', ['text 3'], 'text 4'], 'text 5']) #~ rawText ('test header reference [header1]') rawText ('"blabla"') pageBreak() header ('Test code Block') header ('with string', 2) code1 = 'if (a > 3) { \n moveShip(5 * gravity, DOWN); \n}' codeBlock (code1) header ('with list', 2) code2 = ['if (a > 3) {', ' moveShip(5 * gravity, DOWN);', '}'] codeBlock (code2) header ('fenced with string', 2) codeBlockFenced (code1) newPage() header ('Test line Block') header ('with string', 2) lineBlock1 = 'line 1 \nline 2 \nline 3' lineBlock (lineBlock1) header ('with list', 2) lineBlock2 = ['line 1', 'line 2', 'line 3'] lineBlock (lineBlock2) newPage() header ('Test list Block') header ('bullet list', 2) testList1 = ['ab', ['a', ['a', 'b'], 'b', 'c'], 'b', 'c'] listBlock(testList1) header ('ordered list', 2) testList2 = ['ab', 'bc', 'cd'] orderedlistBlock(testList2) newPage() header ('horizontal rules') horizontalRule () horizontalRule ('*', 4) horizontalRule ('_', 20) newPage() header ('tables') header ('simple table', 2) header ('with header', 3) table1_1 = [ \ [['t1', 'right'],['title2', 'left'],['t3', 'center'], ['t4', 'default']], \ ['12', '12', '123', '12'], \ ['123', '123', '1234', '1234'], \ ['1', '1', '1', '1'] \ ] table1_2 = [ \ [['tt1', 'right', 10],['title2', 'left', 1],['t3', 'center', 10], ['t4', 'default', 40]], \ ['12', '12', '123', '12'], \ ['123', '123', '1234', '1234'], \ ['1', '1', '1', '1'] \ ] table(table1_1, 'table 1_1 caption') newLine() table(table1_2, 'table 1_2 caption') newLine() header ('without header', 3) table2 = [ \ [['', 'right', 10],['', 'left', 5],['', 'center', 2], ['', 'default', 20]], \ ['12', '12', '123', '12'], \ ['123', '123', '1234', '1234'], \ ['1', '1', '1', '1'] \ ] table(table2, 'test', ' ') newPage() header ('multiline table', 2) header ('with header', 3) table3_1 = [ \ [['Centered\nHeader', 'center'],['Default\nAligned', 'default'],['Right\nAligned\ntest', 'right'], ['Left\nAligned', 'left']], \ ['First', 'rowbidule', '12.0', 'Example of a row that\nspans multiple lines.'], \ ['Second', 'row', '5.0', 'Here\'s another one. Note\nthe blank line between\nrows.'], \ ] table(table3_1) header ('without header', 3) table3_2 = [ \ [['', 'center'],['', 'default'],['', 'right', 20], ['', 'left', 50]], \ ['First', 'row', '12.0', 'Example of a row that\nspans multiple lines.'], \ ['Second', 'row', '5.0', 'Here\'s another one. Note\nthe blank line between\nrows.'], \ ] table(table3_2) header ('grid table', 2) header ('with header', 3) table4_1 = [ \ [['Fruit', 'default'],['Price', 'default'],['Advantages', 'default']], \ ['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \ ['Oranges', '$2.10', '- cures scurvy\n- tasty'], \ ] table(table4_1, '', ' ', 'grid') table4_2 = [ \ [['Fruit', 'left', 20],['Price', 'center'],['Advantages', 'right', 30]], \ ['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \ ['Oranges', '$2.10', '- cures scurvy\n- tasty'], \ ] table(table4_2, '', ' ', 'grid') header ('without header', 3) table4_3 = [ \ [['', 'left'],['', 'center'],['', 'right']], \ ['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \ ['Oranges', '$2.10', '- cures scurvy\n- tasty'], \ ] #~ table4_3 = [ \ #~ [['', 'left', 20],['', 'center'],['', 'right', 30]], \ #~ ['Bananas', '$1.34', '- built-in wrapper\n- bright color'], \ #~ ['Oranges', '$2.10', '- cures scurvy\n- tasty'], \ #~ ] table(table4_3, '', ' ', 'grid') header ('pipe table', 2) header ('with header', 3) table5_1 = [ \ [['Right', 'right'],['Left', 'left'],['Default', 'default'], ['Center', 'center']], \ ['12', '12', '123', '12'], \ ['123', '123', '123', '123'], \ ['1', '1', '1', '1'] \ ] table(table5_1, '', ' ', 'pipe') table5_2 = [ \ [['Right\ntruc', 'right'],['Left', 'left', 30],['Default', 'default'], ['Center', 'center']], \ ['12', '12', '123', '12'], \ ['123', '123', '123', '123'], \ ['1', '1', '1', '1'] \ ] table(table5_2, '', ' ', 'pipe') header ('without header', 3) table5_3 = [ \ [['', 'right'],['', 'left'],['', 'default'], ['', 'center']], \ ['12', '12', '123', '12'], \ ['123', '123', '123', '123'], \ ['1', '1', '1', '1'] \ ] table(table5_3, '', ' ', 'pipe') newPage() header ('text formatting') header ('emphase', 2) rawText('this is an ' + italic('italic') + ' emphase') newLine() rawText('this is a ' + bold('bold') + ' emphase') newLine() header ('strikeout', 2) rawText('this is a ' + strikeout('strike out')) newLine() header ('power and indice', 2) rawText('power : 2' + power('10')) newLine() rawText('indice : H' + indice('2') + '0') newLine() header ('verbatim', 2) rawText('verbatim text : ' + verbatim('this is a verbatim text') + '\n') rawText('verbatim text : ' + verbatim('this is a `verbatim` text')) newLine() header ('small caps', 2) rawText('small caps text : ' + smallCaps('this is a smallcaps text')) header ('math', 2) ## tex math format shall be used with \\ for special char formula = '\\sqrt{\\frac{x^2}{3}}' rawText('math formula : ' + math(formula)) newLine() newPage() header ('references') header ('automatic link', 2) urlLink = url('http://google.com') emailLink = email('sam@green.eggs.ham') rawText('url : ' + urlLink) rawText('email : ' + emailLink) newLine() header ('inline link', 2) header ('url', 3) inlineLink = url('http://fsf.org', 'inline link', 'click here for a good time!') rawText('This is an ' + inlineLink) header ('email', 3) inlineLink = email('sam@green.eggs.ham', 'Write me !') rawText(inlineLink) newLine() header ('reference link', 2) header ('non implicit', 3) referenceLink = reference('FSF', 'My Website') rawText('See ' + referenceLink) newLine() header ('implicit', 3) referenceLink = reference('My Website') rawText('See ' + referenceLink) newLine() header ('internal link', 2) headerLink = reference('#introduction', 'Introduction') rawText ('See the ' + headerLink) newLine() rawText ('Or') newLine() headerLink = reference('Introduction') rawText ('See the ' + headerLink) newLine() header ('images', 2) imageRef = image('la_lune.jpg', 'la lune', 'Voyage to the moon') rawText('An image : ' + imageRef) newLine() imageRef = image('la_lune.jpg', width = '50%') rawText('An image : ' + imageRef) newLine() imageRef = image('Blade Runner') rawText('An image : ' + imageRef) newLine() imageRef = image('logo.png', 'SVG Logo', 'SVG Logo', width = '50%') rawText('An image : ' + imageRef) newLine() header ('definition', 2) definedReference('http://fsf.org', 'FSF', 'click here for a good time!') definedReference('http://truc.org', 'My Website') definedReference('#introduction', 'Introduction') definedReference('BladeRunner.gif', 'Blade Runner', 'title', 'width=10cm height=20px') newLine() newPage() header('footnote') header('reference with label', 2) f1 = footnote() f2 = footnote('longFoot') rawText('this is a simple footnote ' + f1 + ' and a long one ' + f2) newLine() header('inline footnote', 2) f3 = footnote(text = 'Inlines notes are easier to write, since \nyou don\'t have to pick an identifier and move down to type the \nnote.') rawText('Here is an inline note.' + f3) newLine() header('definition', 2) definedFootnote('1', 'A simple footnote.') definedFootnote('longFoot', 'Here\'s one with multiple blocks.\n\nSubsequent paragraphs are indented to show that they\nbelong to the previous footnote.\n\nThe whole paragraph can be indented, or just the first \nline. In this way, multi-paragraph footnotes work like \nmulti-paragraph list items.', '\n') newLine() newPage() header('citations') c1 = citations('See @doe99', 'pp. 33-35', '@smith04') rawText('Blah blah ' + c1 + '\n') c2 = citations('@doe99', '@smith04') rawText('Blah blah ' + c2 + '\n') c3 = citations('@doe99', 'pp. 33-35, 38-39') rawText('Blah blah ' + c3 + '\n') c4 = citations('-@doe99') rawText('Blah blah ' + c4 + '\n') addBibliography('./biblio.bib') finalizeDocument() #~ printDocument () #~ serialize ('test.md') convert('test.pdf', 'latex') if __name__ == "__main__": main () #~ sys.exit (0); # exit