Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
EmilyGraceSeville7cf opened this issue Mar 7, 2023 · 2 comments
Assignees
Labels
bug Something isn't working parser

Comments

@EmilyGraceSeville7cf
Copy link
Member

EmilyGraceSeville7cf commented Mar 7, 2023

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.

@EmilyGraceSeville7cf EmilyGraceSeville7cf added the bug Something isn't working label Mar 7, 2023
@EmilyGraceSeville7cf EmilyGraceSeville7cf self-assigned this Mar 7, 2023
@EmilyGraceSeville7cf
Copy link
Member Author

Solution: introduce escaping for tags.

@EmilyGraceSeville7cf
Copy link
Member Author

Another input page:

# pacman

> Arch Linux package manager utility
> Some subcommands such as `pacman sync` have their own usage documentation
> For equivalent commands in other package managers, see <https://wiki.archlinux.org/title/Pacman/Rosetta>
> More information: https://man.archlinux.org/man/pacman.8

- Synchronize and update all packages:

`sudo pacman -Syu`

- Install a new package:

`sudo pacman -S {string value: package_name}`

- Remove a package and its dependencies:

`sudo pacman -Rs {string value: package_name}`

- Search the package database for a regular expression or keyword:

`pacman -Ss "{string value: search_pattern}"`

- List installed packages and versions:

`pacman -Q`

- List only the explicitly installed packages and versions:

`pacman -Qe`

- List orphan packages (installed as dependencies but not actually required by any package):

`pacman -Qtdq`

- Empty the entire pacman cache:

`sudo pacman -Scc`

being "prettified" to this one:

# pacman

> Arch Linux package manager utility
> Some subcommands such as `pacman sync` have their own usage documentation

- Synchronize and update all packages:

`sudo pacman -Syu`

- Install a new package:

`sudo pacman -S {string value: package_name}`

- Remove a package and its dependencies:

`sudo pacman -Rs {string value: package_name}`

- Search the package database for a regular expression or keyword:

`pacman -Ss "{string value: search_pattern}"`

- List installed packages and versions:

`pacman -Q`

- List only the explicitly installed packages and versions:

`pacman -Qe`

- List orphan packages (installed as dependencies but not actually required by any package):

`pacman -Qtdq`

- Empty the entire pacman cache:

`sudo pacman -Scc`

@EmilyGraceSeville7cf EmilyGraceSeville7cf changed the title Parser breaks pages while reformatting sometimes Parser breaks pages while reformatting sometimes when CHECK is unset Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser
Projects
None yet
Development

No branches or pull requests

1 participant