@thetimes/methode-parser
<h1>Times legacy content parser</h1>
Last updated 2 months ago by tnlweb .
MIT · Original npm · Tarball · package.json
$ cnpm install @thetimes/methode-parser 
SYNC missed versions from official npm registry.

Times legacy content parser

The purpose of this package is to convert data into ASTs.

Content to Markup

This function converts arrays of elements of the form,

[
  {
    type: "paragraph",
    data: {
      attributes: {},
      text:
      "I love cheese. I have always loved cheese. Cheese tastes a lot better than dirty socks."
    }
  },
  {
    type: "paragraph",
    data: {
      attributes: {},
      text: "I had a <i>dream</i> <b>today</b>"
    }
  },
  {
    type: "image",
    data: {
      caption: "caption",
      credits: "credits",
      display: "primary",
      height: "200",
      horizontalOffset: "1",
      imageId: "id.jpg",
      ratio: "3:2",
      verticalOffset: "1",
      width: "200"
    }
  },
  ...
]

into fully parsed markup elements, leaving no string unparsed.

In particular, paragraphs with rich text will be turned into markup of the form,

[
  {
    "name": "paragraph",
    "children": [
      {
        "name": "text",
        "attributes": {
          "value": "Some ",
        },
        "children": []
      },
      {
        "name": "italic",
        "children": [
          {
            "name": "text",
            "attributes": {
              "value": "styled",
            },
            "children": []
          }
        ]
      },
      {
        "name": "text",
        "attributes": {
          "value": " text within ",
        },
        "children": []
      },
      {
        "name": "bold",
        "children": [
          {
            "attributes": {
              "value": "the",
            },
            "children": [],
            "name": "text",
          }
        ]
      },
      {
        "name": "text",
        "attributes": {
          "value": " paragraph",
        },
        "children": []
      }
    ]
  }
]

Author to Markup

This function turns text containing an author name into markup elements.

Example input,

const authorSlugs = [
  "john-doe",
  "sponge-bob"
];

const authorDescription = "Sponge Bob, Jane Doe and John Doe";

authorToByline(authorDescription);

Example output,

[
  {
    "name": "author",
    "attributes": {
      "slug": "sponge-bob",
    },
    "children": [
      {
        "name": "text",
        "attributes": {
          "value": "Sponge Bob",
        },
        "children": [],
      },
    ],
  },
  {
    "name": "inline",
    "children": [
      {
        "attributes": {
          "value": ", Jane Doe and ",
        },
        "children": [],
        "name": "text",
      },
    ],
  },
  {
    "name": "author",
    "attributes": {
      "slug": "john-doe",
    },
    "children": [
      {
        "name": "text",
        "attributes": {
          "value": "John Doe",
        },
        "children": []
      }
    ]
  }
]

Current Tags

  • 7.0.16                                ...           latest (2 months ago)

30 Versions

  • 7.0.16                                ...           2 months ago
  • 7.0.15                                ...           3 months ago
  • 7.0.14                                ...           3 months ago
  • 7.0.13                                ...           4 months ago
  • 7.0.12                                ...           4 months ago
  • 7.0.11                                ...           4 months ago
  • 7.0.10                                ...           5 months ago
  • 7.0.7                                ...           5 months ago
  • 7.0.9                                ...           5 months ago
  • 7.0.6                                ...           a year ago
  • 7.0.5                                ...           a year ago
  • 7.0.4                                ...           a year ago
  • 7.0.3                                ...           a year ago
  • 7.0.2                                ...           a year ago
  • 7.0.1                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 6.2.1                                ...           2 years ago
  • 6.2.0                                ...           2 years ago
  • 6.1.0                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.1.3                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 11
Dependencies (4)
Dev Dependencies (10)

Copyright 2014 - 2016 © taobao.org |