npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zentered/issue-forms-body-parser

v2.2.0

Published

Parser for GitHub Issue Form body, also available as GitHub Action

Downloads

914

Readme

GitHub Issue Forms Body Parser

Test Release Conventional Commits zentered.co

Issue Forms is a great way to structure GitHub Issues to an expected format, and to make it easier to capture information from the user. Unfortunately, the schema only defined the input of the data, not the output. So the markdown body needs to be parsed to extract the information in a structured way and to make further processing easier.

We use this Action at the Cyprus Developer Community to create issues with event data for upcoming meetups etc. The parser extracts the information from the issues and provides structured data to create calendar entries (ie .ics files for calendar subscriptions with GitEvents), calling 3rd party APIs, etc.

Inspired by: Peter Murray's Issue Forms Body Parser with valuable feedback from Steffen

Features

  • :white_check_mark: npm version available npm i @zentered/issue-forms-body-parser
  • :white_check_mark: parse question/answer format into title/text as JSON
  • :white_check_mark: parse line items and "tasks" with separate checked attributes
  • :white_check_mark: slugify title to id to find data
  • :white_check_mark: parse dates and times into separate date and time fields
  • :negative_squared_cross_mark: no tokens/input required
  • :negative_squared_cross_mark: zero configuration

Transforms markdown from GitHub Issue Forms:

### Event Description

Let's meet for coffee and chat about tech, coding, Cyprus and the newly formed
CDC (Cyprus Developer Community).

### Location

Cafe Nero Finikoudes, Larnaka

### Date

11.03.2022

### Time

16:00

to structured, usable data:

{
  "event-description": {
    "order": 0,
    "title": "Event Description",
    "text": "Let's meet for coffee and chat about tech, coding, Cyprus and the newly formed\nCDC (Cyprus Developer Community)."
  },
  "location": {
    "order": 1,
    "title": "Location",
    "text": "Cafe Nero Finikoudes, Larnaka"
  },
  "date": {
    "order": 2,
    "title": "Date",
    "text": "11.03.2022",
    "date": "2022-03-11"
  },
  "time": {
    "order": 3,
    "title": "Time",
    "text": "16:00",
    "time": "16:00"
  }
}

See more examples in md test cases and test results.

Parsers

  • date: checks if the value matches a common date format and returns a formatted date field (in UTC).
  • time: checks if the value matches a common time format and returns a formatted time field.
  • lists: automatically returns lists as arrays
  • duration: currently only the format XXhYYm is supported as duration, ie. 1h30m returns a duration object with hours and minutes.

Installation & Usage

GitHub Actions

name: Issue Forms Body Parser

on: issues

jobs:
  process:
    runs-on: ubuntu-latest
    steps:
      - name: Issue Forms Body Parser
        id: parse
        uses: zentered/[email protected]
      - run: echo ${{ toJSON(steps.parse.outputs.data) }}

You can also provide a custom body input:

name: Issue Forms Body Parser

on:
  workflow_dispatch:
    inputs:
      issue_number:
        type: string
        required: true
env:
  GH_TOKEN: ${{ github.token }}

jobs:
  process:
    runs-on: ubuntu-latest
    steps:
      - name: Fetch the issue
        id: read_issue_body
        run:
          echo "body=$(gh issue view ${{ inputs.issue_number }} --repo ${{
          github.repo }} --json body --jq '.body')" >> $GITHUB_OUTPUT

      - name: Issue Forms Body Parser
        id: parse
        uses: zentered/[email protected]
        with:
          body: ${{ steps.read_issue_body.output.body }}

      - run: echo ${{ toJSON(steps.parse.outputs.data) }}

NPM

The parser is available as a standalone library:

    npm i @zentered/issue-forms-body-parser
    # OR yarn add @zentered/issue-forms-body-parser

Usage:

import bodyParser from '@zentered/issue-forms-body-parser'
const issueData = await bodyParser(issue.body)

Development & Testing

You can use act to test this Action locally.

npm run build && act issues -e test/issue.json

or run:

npm test

to test the parser.

Links

License

Licensed under MIT.

Here is a list of all the licenses of our production dependencies