feat: Add language syntax support for color code (#128)

- feat: text highlight
- fix: wrong env, typo
This commit is contained in:
Jisan 2023-06-02 11:17:41 +05:30 committed by GitHub
parent d26ed33e7a
commit da0f4f1847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -82,6 +82,7 @@ There are many flags that you can tweak to suit your taste!
| `REPOSITORY` | `<gh_username>/<gh_username>` | `<gh_username>/<repo_name>` | Waka-readme stats will appear on the provided repository | | `REPOSITORY` | `<gh_username>/<gh_username>` | `<gh_username>/<repo_name>` | Waka-readme stats will appear on the provided repository |
| `SECTION_NAME` | `waka` | Any alphanumeric string | The generator will look for this section to fill up the readme. | | `SECTION_NAME` | `waka` | Any alphanumeric string | The generator will look for this section to fill up the readme. |
| `COMMIT_MESSAGE` | `Updated waka-readme graph with new metrics` | Any string | Messaged used when committing updated stats | | `COMMIT_MESSAGE` | `Updated waka-readme graph with new metrics` | Any string | Messaged used when committing updated stats |
| `CODE_LANG` | `txt` | `python` `ruby` `json` , you can use other languages also | Language syntax to format the generated text, to get colored text. |
| `SHOW_TITLE` | `false` | `false`, `true` | Add title to waka-readme stats blob | | `SHOW_TITLE` | `false` | `false`, `true` | Add title to waka-readme stats blob |
| `BLOCKS` | `░▒▓█` | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, you can be creative! | Ascii art used to build stats graph | | `BLOCKS` | `░▒▓█` | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, you can be creative! | Ascii art used to build stats graph |
| `TIME_RANGE` | `last_7_days` | `last_7_days`, `last_30_days`, `last_6_months`, `last_year`, `all_time` | String representing a dispensation from which stats are aggregated | | `TIME_RANGE` | `last_7_days` | `last_7_days`, `last_30_days`, `last_6_months`, `last_year`, `all_time` | String representing a dispensation from which stats are aggregated |

View File

@ -44,6 +44,11 @@ inputs:
default: "░▒▓█" default: "░▒▓█"
required: false required: false
CODE_LANG:
description: "Add syntax formatter for generated code"
default: "txt"
required: false
TIME_RANGE: TIME_RANGE:
description: "Time range of the queried statistics" description: "Time range of the queried statistics"
default: "last_7_days" default: "last_7_days"

View File

@ -143,6 +143,7 @@ class WakaInput:
commit_message: str = os.getenv( commit_message: str = os.getenv(
'INPUT_COMMIT_MESSAGE', 'Updated WakaReadme graph with new metrics' 'INPUT_COMMIT_MESSAGE', 'Updated WakaReadme graph with new metrics'
) )
code_lang: str = os.getenv('INPUT_CODE_LANG', 'txt')
_section_name: str = os.getenv('INPUT_SECTION_NAME', 'waka') _section_name: str = os.getenv('INPUT_SECTION_NAME', 'waka')
start_comment: str = f'<!--START_SECTION:{_section_name}-->' start_comment: str = f'<!--START_SECTION:{_section_name}-->'
end_comment: str = f'<!--END_SECTION:{_section_name}-->' end_comment: str = f'<!--END_SECTION:{_section_name}-->'
@ -414,7 +415,7 @@ def churn(old_readme: str, /):
# substituting old contents # substituting old contents
new_readme = re.sub( new_readme = re.sub(
pattern=wk_i.waka_block_pattern, pattern=wk_i.waka_block_pattern,
repl=f'{wk_i.start_comment}\n\n```text\n{generated_content}\n```\n\n{wk_i.end_comment}', repl=f'{wk_i.start_comment}\n\n```{wk_i.code_lang}\n{generated_content}\n```\n\n{wk_i.end_comment}',
string=old_readme string=old_readme
) )
if len(sys.argv) == 2 and sys.argv[1] == '--dev': if len(sys.argv) == 2 and sys.argv[1] == '--dev':