{"id":2317,"date":"2014-10-08T13:54:52","date_gmt":"2014-10-08T11:54:52","guid":{"rendered":"https:\/\/test.viaboxx.de\/2014\/10\/08\/confluence2md\/"},"modified":"2021-08-10T22:21:04","modified_gmt":"2021-08-10T22:21:04","slug":"confluence2md","status":"publish","type":"post","link":"https:\/\/www.viaboxx.de\/en\/blog\/confluence2md\/","title":{"rendered":"Generate nice documents out of Confluence"},"content":{"rendered":"\n<p><strong>Problem:<\/strong><\/p>\n\n\n\n<p>Your company is using <a href=\"https:\/\/www.atlassian.com\/de\/software\/confluence\">Confluence<\/a> and this is the place, where the employees write their documents, maintain the links between the pages etc.<\/p>\n\n\n\n<p>You have to deliver high-quality documents (documentation, manuals etc.) to your customer, so you have to produce PDF or Word-files. The customer wants you to use specific templates with header-page, logo, table of contents.<\/p>\n\n\n\n<p>How can you bring the content of the Confluence pages into the documents for shipping?<\/p>\n\n\n\n<p>You could write the documentation with word, you can copy-paste the confluence pages into word files, you can use the export functions of confluence to export pages as PDF or Word files, but: all those options are either manual effort, hard to maintain or do not produce documents in the format that you can control.<\/p>\n\n\n\n<p>What you want is a customizable solution, that even can be 100% automated to have docments with up-to-date content ready to deliver at any time.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p><strong>Idea:<\/strong><\/p>\n\n\n\n<p>So the idea is to use the Confluence2MD tool to retrieve the pages out of confluence and convert them into a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Markdown\">Markdown<\/a> file. A markdown file is&nbsp; a text file and the <a href=\"http:\/\/johnmacfarlane.net\/pandoc\/\">PanDoc<\/a> tool, can convert such files into various formats, e.g. Word or PDF.<\/p>\n\n\n\n<p>You can use master-\/child documents to bring the generated documents into a document that contains a table-of-content etc.<\/p>\n\n\n\n<p><strong>Use Confluence2MD from maven-central<\/strong><\/p>\n\n\n\n<p>Confluence2MD is a tool written by Viaboxx, published as open source (Apache 2.0 license). The artifacts can be retrieved from <a href=\"http:\/\/search.maven.org\/\">maven-central<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[codesyntax lang=\"xml\" lines=\"no\"]\n&lt;pre>&amp;lt;dependency&amp;gt;\n  &amp;lt;groupId&amp;gt;de.viaboxx.markdown&amp;lt;\/groupId&amp;gt;\n  &amp;lt;artifactId&amp;gt;confluence2md&amp;lt;\/artifactId&amp;gt;\n  &amp;lt;version&amp;gt;1.5.2&amp;lt;\/version&amp;gt;\n  &amp;lt;classifier&amp;gt;fat&amp;lt;\/classifier&amp;gt;\n&amp;lt;\/dependency&amp;gt;&lt;\/pre>\n[\/codesyntax]<\/pre>\n\n\n\n<p>confluence2md supports to retrieve your confluence pages with the REST\/HTTP API and converts a document hierarchy into a markdown file. It supports links to other chapters or external URLs, tables, lists, codeblocks and images. It even renders diagrams described with the <a href=\"http:\/\/plantuml.sourceforge.net\/\">PlantUML<\/a> syntax as images.<\/p>\n\n\n\n<p>To run the tool, you need a <a href=\"http:\/\/www.oracle.com\/technetwork\/java\">JRE<\/a> (java version 7 or newer).<\/p>\n\n\n\n<p><strong>Install Pandoc<\/strong><\/p>\n\n\n\n<p>To convert the Markdown file to any document format, you need to install Pandoc.<\/p>\n\n\n\n<p>see <a href=\"http:\/\/johnmacfarlane.net\/pandoc\/\">http:\/\/johnmacfarlane.net\/pandoc\/<\/a><\/p>\n\n\n\n<p><strong>Usage<\/strong><\/p>\n\n\n\n<p>See the usage of confluence2md about the possible options:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>-m wiki|file|url<br>specify input format\/processing mode (default: wiki)<\/li><li>-o file<br>specify output format, charset=UTF-8&nbsp; (default: stdout, charset=file.encoding of plaform)<\/li><li>-oa file<br>specify output format, charset=UTF-8 &#8211; open for append!<\/li><li>-v true<br>for verbose output&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (default: false)<\/li><li>-u user:password<br>to use HTTP-Basic-Auth to request the URL (default: no auth)<\/li><li>-depth -1..n<br>the depth to follow down the child-pages hierarchy. -1=infinte, 0=no children (default: -1)<\/li><li>-server URL<br>URL of confluence server. used in wiki-mode (default: https:\/\/viaboxx.atlassian.net\/wiki)<\/li><li>-plantuml<br>turn off integrated run of PlantUML to render diagrams (default is to call PlantUML automatically)<\/li><li>-a folder<br>download folder for attachments (default: attachments)<\/li><li>+H true\/false true: document hierarchy used to generate page header format type (child document =&gt; h2 etc) (default: true)<\/li><li>+T true\/false<br>true: title transformation ON (cut everything before first -) (default: true)<\/li><li>+RootPageTitle true\/false<br>true: generate header for root page, false: omit header of root page (default: true)<\/li><li>&nbsp;+FootNotes true\/false true:generate foot notes, false: no foot notes (default: true)<\/li><li>&nbsp;-maxHeaderDepth 1..n the maximum header depth that will be rendered as a header, deeper will only rendered as bold title (default: 5)<\/li><li>last parameter:<br>the file to read&nbsp; (-m file) or the URL to get (-m url) or the pageId to start with (-m wiki)<\/li><\/ul>\n\n\n\n<p>Call the pandoc tool to convert the markdown file (.md) to the document format of your choice.<\/p>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[codesyntax lang=\"bash\" lines=\"no\"]\n&lt;pre>java -jar confluence2md-fat.jar +T true +H true +RootPageTitle true -v -o docFromWiki.md -u myUser:myPassword -server https:\/\/viaboxx.atlassian.net\/wiki 3408268\npandoc -f markdown+hard_line_breaks -N --template default.tex -o docFromWiki.docx docFromWiki.md&lt;\/pre>\n[\/codesyntax]<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>&nbsp;&#8220;3408268&#8221; is a pageId in the wiki at &#8220;https:\/\/viaboxx.atlassian.net\/wiki&#8221;<\/li><li>the wiki requires basic authentication as user=myUser with password=myPassword<\/li><li>&#8220;+T true&#8221; enables title-transformation.<br>e.g. when a Confluence-page is named &#8220;Technical manual &#8211; Introduction&#8221; the chapter in the result document would be transformed to &#8220;Introduction&#8221;.<br>The text after the first &#8220;-&#8221; will be used as chapter title.<br>This helps to get a determined sequence of sub-chapters: You can name the child pages as &#8220;1 &#8211; Install&#8221;, &#8220;2 &#8211; Getting Started&#8221;, etc. because Confluence returns them ordered by page title alphabetically.<\/li><li>The result from running confluence2md is a markdown file named &#8220;docFromWiki.md&#8221;<\/li><li>The result from running pandoc is a word docx file named &#8220;docFromWiki.docx&#8221;<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Your company is using Confluence and this is the place, where the employees write their documents, maintain the links between the pages etc. You have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6993,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[76],"tags":[],"class_list":["post-2317","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code"],"uagb_featured_image_src":{"full":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md.jpg",2200,700,false],"thumbnail":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md-150x150.jpg",150,150,true],"medium":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md-300x95.jpg",300,95,true],"medium_large":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md-768x244.jpg",768,244,true],"large":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md-1024x326.jpg",1024,326,true],"1536x1536":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md-1536x489.jpg",1536,489,true],"2048x2048":["https:\/\/www.viaboxx.de\/wp-content\/uploads\/2014\/10\/Blog-Post-confluence2md-2048x652.jpg",2048,652,true]},"uagb_author_info":{"display_name":"Simon Tiffert","author_link":"https:\/\/www.viaboxx.de\/en\/blog\/author\/simon-tiffertviaboxx-de\/"},"uagb_comment_info":1,"uagb_excerpt":"Problem: Your company is using Confluence and this is the place, where the employees write their documents, maintain the links between the pages etc. You have [&hellip;]","_links":{"self":[{"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/posts\/2317"}],"collection":[{"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/comments?post=2317"}],"version-history":[{"count":2,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/posts\/2317\/revisions"}],"predecessor-version":[{"id":6995,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/posts\/2317\/revisions\/6995"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/media\/6993"}],"wp:attachment":[{"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/media?parent=2317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/categories?post=2317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.viaboxx.de\/en\/wp-json\/wp\/v2\/tags?post=2317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}