How to shift table in markdown file? - tfs

I have a table in README.md file in TFS like this:
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
It's work. But I need to shift this table to the right by tab character. And if I place tab (or space character) before table rows it's not recognize as table and just print as plain text. HTML tag also doesn't work in TFS.
How I can move table?

Unfortunately shift table is not supported in Markdown.
Markdown does not provide any special syntax for tables.
Please see Syntax guidance for Markdown files, widgets, wikis, and pull request comments for details.
I can think of is that you can capture a screenshot for the table, render the captured image, check in the image, then Add image to your Markdown file.
But please note that just as Waylan mention in below comments : For screenshot of a table, the text will no longer be searchable and cannot be copy and pasted by the user. And any future edits will require recreating the entire table.

Related

Unwrapping a Markdown table with a Pandoc Lua filter

I have a DOCX file with this content:
# Heading
+---------------------+
| Paragraph |
| |
| ## Subheading |
| |
| +-----------------+ |
| | Nested table | |
| +-----------------+ |
+---------------------+
One last paragraph
Here is a sample file.
I want to run it through Pandoc and get this Markdown, with all tables unwrapped:
# Heading
Paragraph
## Subheading
Nested table
One last paragraph
I'm trying to write a Lua filter with walk_block but I have no experience with Lua and not making any progress. Can anyone point me in a helpful direction?
function Table(table)
pandoc.walk_block(table, {
Str = function(el)
-- TODO now what???
end
})
end
The Lua interface to tables is currently rather complex, so it's much simpler to convert the table into a so-called simple table. We can do so with pandoc.utils.to_simple_table. A simple table has a header row (header) and multiple body rows (rows), and we get access to cells by iterating over a row. Each cell is just a Blocks list, which we can collect in an accumulator.
Here's how this looks like:
function Table (tbl)
local simpleTable = pandoc.utils.to_simple_table(tbl)
local blocks = pandoc.Blocks{}
for _, headercell in ipairs(simpleTable.header) do
blocks:extend(headercell)
end
for _, row in ipairs(simpleTable.rows) do
for _, cell in ipairs(row) do
blocks:extend(cell)
end
end
return blocks, false
end
Running that filter should unwrap all tables, leaving just their contents.

How to insert hard line break in Quarto document

I'm working with the Quarto document preparation system to programmatically generate large documents using Python. That is I am not using the RStudio or similar editor. All text must be generated as Python strings.
I have a simple table where one cell has several lines worth of content and I figure that I can add line-breaks within the cell. I understand that simple tables cannot include standard line breaks (\n) but I'm wondering if there is a way to insert so-called "hard-line-breaks" in cells. The user manual mentions them but states that only the editor can insert them. Is it possible to do this using string operations in the markdown source text?
Barring that is there a simple way to break lines within a cell in a table?
Quarto tables generated by RStudio visual Markdown editor
There's not much magic involved when it comes to hard line breaks, just lines that end with a \.
QMD file created in RStudio with visual mode enabled, a (Grid) table with both regular and hard line breaks looks like this:
---
title: "tbl"
format: html
editor: visual
---
+-------+-------------+
| Col1 | Col2 |
+=======+=============+
| press | press\ |
| | shift+enter |
| enter | |
+-------+-------------+
| | |
+-------+-------------+
With all the whitespace and linefeeds next to rendered output:
While RStudio visual editor starts with simple pipe tables, it switches automatically to grid tables when it encounters a line break or anything else in a cell that's not supported by simple pipe tables.
Python and grid-style Markdown tables
For generating Markdown grid tables in Python, tabulate with tablefmt="grid" is quite handy. Or pandas.DataFrame.to_markdown() in case of pandas, also built on top of tabulate.
from tabulate import tabulate
td = [["press\n\nenter","press\\\nshift+enter"],["no\nbackslash","",]]
hdr = ["Col1", "Col2"]
print(tabulate(td,headers=hdr, tablefmt="grid"))
Result:
+-----------+-------------+
| Col1 | Col2 |
+===========+=============+
| press | press\ |
| | shift+enter |
| enter | |
+-----------+-------------+
| no | |
| backslash | |
+-----------+-------------+
Rendered with Quarto:
Pandoc multiline tables
For whatever reason this is not mentioned in Quarto docs, but Pandoc also supports multiline_tables and rendering it with Quarto & Pandoc that are bundled with RStudio works fine, though for hard line breaks it still needs \ before a break.
Slighty modified sample from Pandoc documentation:
-------------------------------------------------------------
Centered Default Right Left
Header Aligned Aligned Aligned
----------- ------- --------------- -------------------------
First row 12.0 Example of\
a row that
spans multiple lines.
Second row 5.0 Here's another one. Note
the blank line between
rows.
-------------------------------------------------------------
Table: Here's the caption. It, too, may span\
multiple lines.
Renders as:

How to add the vertical pipes we see in Examples feature of the Scenario Outline in SpecFlow

I would like to add the vertical pipes so that I can have my data table down there under "Examples" feature in Specflow. Anyone to give me any tip so I can go through it?. My scenario outline looks like:
#mytag
Scenario Outline: Check Noun Words
Given Access the AnalyzeStateless URL
And language code
And content of <Sentence>
And the Expected KeyWord <Expected KeyWords>
And the Expected Family ID <Expected FID>
And the index <Index>
When return the XML response
Then the keyword should contain <FamilyID>
Examples:
| Index | Sentence | Expected KeyWords | Expected FID |
| 1 | I need a personal credit card | personal | 92289 |
The "Examples" feature has been manually entered in above case. I have a thousand of rows on an excel file, any appropriate way to get all of the values in one go?
Have you looked at Specflow.Excel which allows you to keep your examples in your excel files?

Repeating steps with different values in BDD test case

I am new to BDD specflow.
I have to write a scenario wherein after I capture an image, i have to select a value for each defined attribute for that image from a selection list
For Eg:
|Body Part |Location |Group |
| Leg | Left | Skin |
| Hand | Upper | Burn |
| Arm | Right | Ulcer |
I need a way in which i can select a different value for each attribute, every time.
Thanks in advance!
You are looking for Scenario Outline;
Scenario outlines allow us to more concisely express these examples through the use of a template with placeholders, using Scenario Outline, Examples with tables and < > delimited parameters.
Specflow takes each line in the Example table and create from the line a scenario to execute.

How to pass spaces in table (specflow scenario)?

How to pass spaces in table ?
Background:
Given the following books
|Author |(here several spaces)Title(here several spaces)|
I would do this:
Given the following books
| Author | Title |
| "J. K. Rowling" | "Harry P " |
| " Isaac Asimov " | "Robots and Empire" |
Then your bindings can be made to strip the quotes if present, but retaining the spaces.
I think this is much preferable to the idea of adding spaces afterward, because that isn't very human readable - quotations will make the spaces visible to the human (stakeholder / coder) reading them.
You can work around it by adding an extra step. Something like:
Given the following books
|Author | Title |
Add append <5> spaces to book title
Edit:
A complete feature can look something like:
Scenario: Adding books with spaces in the title
Given the following book
| price | title |
And <5> spaces appended to a title
When book is saved
Then the title should be equals to <title without spaces>
I just faced same situation, my solution was this, added spaces in the step as follows:
Scenario: Adding books with spaces in the title
Given the following book ' <title> '
When book is saved
Then the title should be equals to '<title>'
| price | title |
| 50.00 | Working hard |

Resources