Skip to content

Commit

Permalink
Ignore lines that don't start with pipe in Mkdwn
Browse files Browse the repository at this point in the history
Only parse lines that start with a pipe for the Markdown table source.
  • Loading branch information
joshbeard committed Oct 7, 2022
1 parent 9ff5a02 commit 9b563ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ following format:
* Use a BEGIN and END comment tag surrounding the table block in a Markdown
document. These begin/end comment strings are configurable.

* Ensure each row of the table begins with a pipe (`|`). It doesn't have to
have one at the end.
* Only lines that begin with a pipe (`|`) are parsed.

* The header names are irrelevant.

Expand All @@ -143,10 +142,11 @@ following format:

* The table column headers are customizable.

* The list of tags may optionally be formatted (e.g. with single backticks,
italics, bold) and can be a comma-separated list of tags with wildcards.
* The tag column may be a single tag or a list of comma-separated tags. The
values can optionally be surrounded in backticks and can use wildcards.

* The deletion date format is customizable. Set the [date format](#date-format).
* The date column should be a single date value in the configured
[date format](#date-format).

## Running

Expand Down Expand Up @@ -176,10 +176,14 @@ Basic usage:
markdown_file: README.md
```
__NOTE:__ You __must__ explicitly set one or both of `json_file` and
`markdown_file` for anything to happen.
* The GitHub Action exposes all of the [environment
variables](#environment-variables) as action inputs. At a minimum, the
`dockerhub_username`, `dockerhub_password`, and `dockerhub_repository` must
be set in addition to `markdown_file` and/or `json_file`.

Setting custom configuration, showing all action inputs:
* Use `v1` for the action version for now.

An example showing all inputs:

```yaml
- name: Docker Hub Tag Deleter
Expand Down
15 changes: 8 additions & 7 deletions hub-tag-delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ def get_readme_table():
for line in md_file:
if line.startswith(config['markdown']['begin_string']):
parsing = True
if parsing and not line_is_ignored(line):
# ignore empty lines
if line.strip():
linenum += 1
# Skip the header and separator (first two lines)
if linenum > 2:
items.append(parse_md_line(line))
if parsing:
if line.startswith('|') and not line_is_ignored(line):
# ignore empty lines
if line.strip():
linenum += 1
# Skip the header and separator (first two lines)
if linenum > 2:
items.append(parse_md_line(line))
if line.startswith(config['markdown']['end_string']):
parsing = False

Expand Down

0 comments on commit 9b563ab

Please sign in to comment.