Search code examples
markdowngithub-flavored-markdown

Difference between Github and npm table markdown


My readme.md Markdown table is shown correctly on npm but not on GitHub.

This is the table markdown:

   Attributes  | Field type | value |  description
- | - | - | -
required | `*`  | boolean`(default=false)` | check if field has a value if set true.
  requiredPhrase | `*`  | string`(default=This field is required.)` | error shown when field is required and empty.
name  | `*`  | string | a unique string in form, on submitting the form you can access a field value by values.`<name>`
placeholder  | `*`  | string`(default=null)` | inputs placeholder.
defaultValue | `*`  | any`(default=null)` | in case of editing forms pass current values via `defaultValue`.
 maxLength | `text`, `number` and `password` | number`(default=null)` | maximum value length.
  maxLengthErrorPhrase | `text`, `number` and `password` | string`(default=This field accepts <maxLength> characters.)` | error shown when maxLength is crossed.
   multiSelect | `select`| boolean`(default=false)` | set true if select can have more than one values.
   selectHandle | `select` | component`(default=an ungly css-made triangle)`, example: `<i className="ion-ios-arrow-down` (which needs ionicons) | this option is for changing the select box handle component.   
   options | `select`, `radio` | array of objects with `label` and `value` | choices for select input and radio group.
   checkboxLabel| `checkbox` | string`(default:'')`| checkbox label.
   mustBeCheckedPhrase| `checkbox` | string`(default:'This field must be checked.')`| error shown when checkbox is required and not checked.

Maybe GitHub uses a different Markdown?


Solution

  • Either add a leading pipe:

    | Attributes  | Field type | value |  description
    | - | - | - | -
    | required | `*` | boolean`(default=false)` | check if field has a value if set true.
    | requiredPhrase | `*` | string`(default=This field is required.)` | error shown when field is required and empty.
    

    or use two (or more) hyphens instead of one so they're not parsed as bullets:

    Attributes  | Field type | value |  description
    -- | -- | -- | --
    required | `*` | boolean`(default=false)` | check if field has a value if set true.
    requiredPhrase | `*` | string`(default=This field is required.)` | error shown when field is required and empty.
    

    I also recommend getting rid of that jagged leading whitespace for readability of the raw Markdown.