Skip to content

Parser breaks pages while reformatting sometimes when CHECK is unset #71

@EmilyGraceSeville7cf

Description

@EmilyGraceSeville7cf

Script being used:

#!/usr/bin/env bash

. ./clip-parse.sh

# shellcheck disable=2155
prettify() {
    declare in_content="$1"

    declare header="$(parser__header "$in_content")"
    declare summary="$(parser_summary__cleaned_up "$in_content")"

    declare examples=
    declare -i count="$(parser_examples__count "$in_content")"

    for ((i = 0; i < count; i++)); do
        declare description="$(parser_examples__description_at "$in_content" "$i")"
        declare code="$(parser_examples__code_at "$in_content" "$i")"

        examples+="- $description:

\`$code\`

"
    done

    echo "# $header

$summary

$examples"
}

declare clip_pages="/home/emilyseville7cfg/Documents/mine/other/cli-pages"

for category_path in "$clip_pages/"*; do
    [[ ! -d "$category_path" ]] && continue

    declare category="${category_path##*/}"
    echo "Refreshing pages in '$category' category"

    for file in "$category_path/"*.clip; do
        prettified="$(prettify "$(cat "$file")")"
        echo "$prettified" > "$file"
        echo "'$file' refreshed"
    done
done

Input page:

# gist

> Upload code to https://gist.github.com
> More information: https://github.com/defunkt/gist

- Log in in gist on this computer:

`gist --login`

- Create a gist from any number of text files:

`gist {file value: sample.txt} {file value: sample.txt}`

- Create a private gist with a description:

`gist --private --description "{string value: A meaningful description}" {file value: sample.txt} `

- Read contents from stdin and create a gist from it:

`{string value: echo "hello world"} | gist`

- List your public and private gists:

`gist --list`

- List all public gists for any user:

`gist --list {string user}`

- Update a gist using the ID from URL:

`gist --update {string value: GIST_ID} {file value: sample.txt}`

Output broken page:

# gist

> 

- Log in in gist on this computer:

`gist --login`

- Create a gist from any number of text files:

`gist {file value: sample.txt} {file value: sample.txt}`

- Create a private gist with a description:

`gist --private --description "{string value: A meaningful description}" {file value: sample.txt}`

- Read contents from stdin and create a gist from it:

`{string value: echo "hello world"} | gist`

- List your public and private gists:

`gist --list`

- List all public gists for any user:

`gist --list {string user}`

- Update a gist using the ID from URL:

`gist --update {string value: GIST_ID} {file value: sample.txt}`

Potentially url in the first string caused such error. I guess Upload code to https was interpreted as an unknown tag name. As a result parser thought that there was no description provided for a command.

Metadata

Metadata

Labels

bugSomething isn't workingparser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions