Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tokusumi/markdown-embed-code
Action to synchronize "any" code in markdown with an external file. No more managing code as plain text.
https://github.com/tokusumi/markdown-embed-code
github-action markdown
Last synced: about 1 month ago
JSON representation
Action to synchronize "any" code in markdown with an external file. No more managing code as plain text.
- Host: GitHub
- URL: https://github.com/tokusumi/markdown-embed-code
- Owner: tokusumi
- License: mit
- Created: 2020-11-16T12:10:38.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-06T00:35:47.000Z (about 2 years ago)
- Last Synced: 2024-05-02T03:12:48.736Z (7 months ago)
- Topics: github-action, markdown
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 28
- Watchers: 1
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# markdown-embed-code
Embedding code into markdown from external file.
Any language's code blocks are available.See [demo repo](https://github.com/tokusumi/readme-code-testing) if you are interested in testing code within README.
## How to use
In markdown, write code block as follows:
````markdown
```python:tests/src/sample.py```
And, you can refer specific lines as
```python:tests/src/sample.py [4-5]
```
````Then, this action referes to `tests/src/sample.py` and modifies markdown as (if something code is written, they are overridden):
```python:tests/src/sample.py
from math import sqrtdef sample(x):
return sqrt(x)```
And, specific lines is refered as
```python:tests/src/sample.py [4-5]
def sample(x):
return sqrt(x)
```NOTE: Read file by passed path, where the top directory in your repo is working directory. If the path is wrong, this action is failed.
### How to use - workflow example
Override README.md and push by action if readme is changed:
```yaml
name: Embed code in READMEon:
pull_request:
branches:
- mainjobs:
embed-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
ref: refs/heads/${{ github.head_ref }}- uses: tokusumi/markdown-embed-code@main
with:
markdown: "README.md"
token: ${{ secrets.GITHUB_TOKEN }}
message: "synchronizing Readme"
silent: true
```### Configuration
| input | description |
| -------------------- | ----------------------------------------------------------------------- |
| token | Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }} |
| markdown (Optional) | Target markdown file path. (default: "README.md") |
| message (Optional) | Commit message for action. (default: "Embedding code into Markdown") |
| no_change (Optional) | Issue comment at no changed (default: "No changes on README!" ) |
| output (Optional) | Output markdown file path. If none, override target file. (default: "") |
| silent (Optional) | No issue comment in silent mode (default: false) |