{"id":120,"date":"2023-11-09T23:11:21","date_gmt":"2023-11-09T22:11:21","guid":{"rendered":"https:\/\/bitwise.exposed\/?p=120"},"modified":"2023-11-10T14:59:51","modified_gmt":"2023-11-10T13:59:51","slug":"azuredevops-wiki","status":"publish","type":"post","link":"https:\/\/bitwise.exposed\/index.php\/2023\/11\/09\/azuredevops-wiki\/","title":{"rendered":"AzureDevOps: wiki"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Azure DevOps Wiki written in Markdown the Pythonic way<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Azure DevOps > wiki is able to interpret HTML an Markdown. <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-surface-brand-secondary-color\">But what if you want to import tables into the Wiki?<\/mark> Please let me know, if there&#8217;s a better way, in the meantime this is my approach.<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6aa4f5718dc15&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6aa4f5718dc15\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"564\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on--pointerdown=\"actions.preloadImage\" data-wp-on--pointerenter=\"actions.preloadImageWithDelay\" data-wp-on--pointerleave=\"actions.cancelPreload\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/bitwise.exposed\/wp-content\/uploads\/2023\/11\/devops_with_markdown_the_pythonic_way-3-1024x564.png\" alt=\"\" class=\"wp-image-126\" srcset=\"https:\/\/bitwise.exposed\/wp-content\/uploads\/2023\/11\/devops_with_markdown_the_pythonic_way-3-1024x564.png 1024w, https:\/\/bitwise.exposed\/wp-content\/uploads\/2023\/11\/devops_with_markdown_the_pythonic_way-3-300x165.png 300w, https:\/\/bitwise.exposed\/wp-content\/uploads\/2023\/11\/devops_with_markdown_the_pythonic_way-3-768x423.png 768w, https:\/\/bitwise.exposed\/wp-content\/uploads\/2023\/11\/devops_with_markdown_the_pythonic_way-3-1536x845.png 1536w, https:\/\/bitwise.exposed\/wp-content\/uploads\/2023\/11\/devops_with_markdown_the_pythonic_way-3-2048x1127.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\tdata-wp-bind--aria-label=\"state.thisImage.triggerButtonAriaLabel\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.thisImage.buttonRight\"\n\t\t\tdata-wp-style--top=\"state.thisImage.buttonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To make the header of a wiki looking pretty, HTML with all it&#8217;s styling options is a good choice. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the rest, the code becomes hard to read and Markdown would be much easier to maintain. But for tables, writing Markdown manually is not an option.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Python offers an easy way to convert CSV files into markdown.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#f2f2f2;color:#0d0d0d\">Python<\/span><span role=\"button\" tabindex=\"0\" data-code=\"import pandas as pd\nimport os\n\nos.getcwd()   # in case you don't know the path to your input file or where you'll write the output file (here line 6 and line 13)\n\ndf = pd.read_csv('..\/???\/input_file.csv', encoding=&quot;utf-8&quot;, sep=&quot;,&quot;) # read\ndf = df.fillna('')        # clear all empty cells 'Nan'\n\n# now convert the csv to markdown\ndf_to_markdown = df.to_markdown(index=False)\n\n# open a text file\ntext_file = open('..\/???\/output_file.txt', &quot;w&quot;)\n#write string to file\ntext_file.write(df_to_markdown)\n#close file\ntext_file.close()\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #AF00DB\">import<\/span><span style=\"color: #000000\"> pandas <\/span><span style=\"color: #AF00DB\">as<\/span><span style=\"color: #000000\"> pd<\/span><\/span>\n<span class=\"line\"><span style=\"color: #AF00DB\">import<\/span><span style=\"color: #000000\"> os<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">os.getcwd()   <\/span><span style=\"color: #008000\"># in case you don&#39;t know the path to your input file or where you&#39;ll write the output file (here line 6 and line 13)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #000000\">df = pd.read_csv(<\/span><span style=\"color: #A31515\">&#39;..\/???\/input_file.csv&#39;<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #001080\">encoding<\/span><span style=\"color: #000000\">=<\/span><span style=\"color: #A31515\">&quot;utf-8&quot;<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #001080\">sep<\/span><span style=\"color: #000000\">=<\/span><span style=\"color: #A31515\">&quot;,&quot;<\/span><span style=\"color: #000000\">) <\/span><span style=\"color: #008000\"># read<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">df = df.fillna(<\/span><span style=\"color: #A31515\">&#39;&#39;<\/span><span style=\"color: #000000\">)        <\/span><span style=\"color: #008000\"># clear all empty cells &#39;Nan&#39;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #008000\"># now convert the csv to markdown<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">df_to_markdown = df.to_markdown(<\/span><span style=\"color: #001080\">index<\/span><span style=\"color: #000000\">=<\/span><span style=\"color: #0000FF\">False<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #008000\"># open a text file<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">text_file = <\/span><span style=\"color: #795E26\">open<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #A31515\">&#39;..\/???\/output_file.txt&#39;<\/span><span style=\"color: #000000\">, <\/span><span style=\"color: #A31515\">&quot;w&quot;<\/span><span style=\"color: #000000\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">#write string to file<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">text_file.write(df_to_markdown)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #008000\">#close file<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">text_file.close()<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it. Style your DevOps wiki header with html and do the rest with Markdown. If you want to use tables in your wiki, just go Pythonic \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure DevOps Wiki written in Markdown the Pythonic way Azure DevOps > wiki is able to interpret HTML an Markdown. But what if you want to import tables into the Wiki? Please let me know, if there&#8217;s a better way, in the meantime this is my approach. To make the header of a wiki looking [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,13],"tags":[],"class_list":["post-120","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-markdown","category-python"],"_links":{"self":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":8,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/posts\/120\/revisions\/136"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/media\/134"}],"wp:attachment":[{"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitwise.exposed\/index.php\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}