Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list key/value pairs in a markdown

Tags:

markdown

There is a way to write a key/value pairs list?

I've tried this:

+ key1: value1
+ key2: value2
+ key3: value3

But the result is not very clean to me..

I've also tried tables:

|    |      |
|----|------|
|key1|value1|
|key2|value2|
|key3|value3|

But tables are not meant for key/value listing (I've for example to leave the heading row blank, that sounds ugly to me..)

like image 781
cl0udw4lk3r Avatar asked Feb 10 '15 10:02

cl0udw4lk3r


People also ask

How do you find the value of key value pairs?

In order to get a key-value pair from a KiiObject, call the get() method of the KiiObject class. Specify the key for the value to get as the argument of the get() method. The value of the key at the first level of the JSON document hierarchy will be obtained.

How do you get a key-value pair in typescript?

Use an index signature to define a key-value pair in TypeScript, e.g. const employee: { [key: string]: string | number } = {} . An index signature is used when we don't know all the names of a type's keys ahead of time, but we know the shape of their values. Copied!

Which list are name value pairs in HTML?

Name-value pairs are represented by a set of text strings in which name="value" are usually separated by commas, semicolons, space or newline character.

How do I create a checkbox in markdown?

In Markdown applications that support task lists, checkboxes will be displayed next to the content. To create a task list, add dashes ( - ) and brackets with a space ( [ ] ) in front of task list items. To select a checkbox, add an x in between the brackets ( [x] ).


3 Answers

GitHub Flavored Markdown does not apparently provide for definition lists. It indicates to do it in raw HTML:

<dl>
    <dt>Definition list</dt>
    <dd>Is something people use sometimes.</dd>

    <dt>Markdown in HTML</dt>
    <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
like image 172
aljabear Avatar answered Oct 03 '22 21:10

aljabear


The answer will depend heavily on the Markdown flavour and processor you are using. Regular Markdown doesn't support tables or definition lists, though it does support inline HTML.

Pandoc and PHP Markdown Extra both support definition lists:

key1
: value 1

key2
: value 2

If you are not working with a version of Markdown that supports definition lists you could add HTML <dl>, <dt>, and <dd> tags manually. Of course, the stylesheet being used will affect their display. Stack Overflow shows them as essentially an unordered list without bullets, which isn't very useful.

Alternatively you could use regular lists and re-indent your values with four spaces, e.g.

* key1
    * value1
* key2
    * value2

You could use inline bold or italics to visually separate the key from the value, e.g.

* **key1**: value1
* **key2**: value2

Finally, as you suggested in your question, you could use a table if your version of Markdown supports it.

like image 40
Chris Avatar answered Oct 03 '22 19:10

Chris


Github will render a block of key value pairs as table with a header row if you fence it with three dashes ---

For example:

---
layout: classic-docs
title: "Caching in CircleCI"
short-title: "Caching"
description: "Caching strategies to increase build speeds"
categories: [configuring-jobs]
order: 20
---

renders as: enter image description here

like image 44
notpeter Avatar answered Oct 03 '22 21:10

notpeter