Giter VIP home page Giter VIP logo

markdown-embed-code's Introduction

markdown-embed-code

Embedding code into markdown from external file. Any language's code blocks are available.

See demo repo if you are interested in testing code within README.

How to use

In markdown, write code block as follows:

```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):

from math import sqrt


def sample(x):
    return sqrt(x)

And, specific lines is refered as

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:

name: Embed code in README

on:
  pull_request:
    branches:
      - main

jobs:
  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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.