Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/superwalnut/markdown-gist-transform
transform markdown code into gist
https://github.com/superwalnut/markdown-gist-transform
Last synced: about 1 month ago
JSON representation
transform markdown code into gist
- Host: GitHub
- URL: https://github.com/superwalnut/markdown-gist-transform
- Owner: superwalnut
- License: mit
- Created: 2020-09-15T14:00:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-13T06:31:31.000Z (over 3 years ago)
- Last Synced: 2024-11-01T23:05:31.585Z (2 months ago)
- Language: C#
- Size: 149 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MD-Gist - a .net core tool to transform your markdown code with gist
> This is a markdown tool to transform markdown codes to gist links, it will create gists from the embeded code blocks in your markdown blog posts. It saves embeded gist block in formats of dev.to, medium and hugo blogs. You can also publish your markdown post to dev.to and medium as well.
**Pre-request**
- .Net Core 3.1
- Github auth token
- Medium auth token (Optional, for publishing)
- Dev.to apikey (Optional, for publishing)## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Support](#support)
- [License](#license)## Features
> You can manage your blog posts in a github repository with markdown formats. And use these blogs to transform it with gist for better publishing.
- parse command
Discover mardown files for specified folder and transform all code blocks into gist link. It requires you to specify github auth token to create cosresponding gist files.First you need to create a github access token.
To create the token, go to [Github Create Access Token](https://github.com/settings/tokens/new)
![Github Access Token](./readme-images/github-access-token.png)And make sure you select the Gist scope.
![Gist Scope](./readme-images/gist-scope.png)
``` bash
$ md-gist parse -f= -t=
```If the command successfully run, you would see a number of generated `.md` files. e.g.
```
create-dotnet-core-console-app-with-autofac-dependency-injection-[Dev.to].md
create-dotnet-core-console-app-with-autofac-dependency-injection-[Hugo].md
create-dotnet-core-console-app-with-autofac-dependency-injection-[Medium].md
create-dotnet-core-console-app-with-autofac-dependency-injection-[Jekyll].md
create-dotnet-core-console-app-with-autofac-dependency-injection.md
```
If you open any of them, you should see all the code blocks are replaced with a gist link (or embeded code).e.g.
for Hugo blog, it replaces the code blocks as
```
{{< gist superwalnut b92assadasdb5e58301cab0c28d3cf34d08 >}}
```for Dev.to, it replaces as,
```
{% gist https://gist.github.com/superwalnut/b92434ccbxxx01cab0c28d3cf34d08 %}
```for Medium, it simply replaces as a gist link (when publishing to medium as markdown format, it will convert to proper embeded block)
```
https://gist.github.com/superwalnut/b92434xxx8301cab0c28d3cf34d08
```for jekyll, it replaces as,
```
{% gist c08ee0f272xxxx09d %}
```- devto command
Use this to publish your post to Dev.to blogFirst you need to create dev.to api keys in your [account settings](https://dev.to/settings/account)
![API key](./readme-images/dev-to-apikey.png)
```
$ md-gist devto -f= -k= -s=
```- medium command
Use this to publish your post to MediumFirst you need to create medium integration token in [account settings](https://medium.com/me/settings)
![Medium Integration Token](./readme-images/medium-token.png)
```
$ md-gist medium -f= -t= -s=
```## Installation
- Using `dotnet tool install --global MD-Gist` to install the console tool from nuget
``` shell
$ dotnet tool install --global MD-Gist
```---
### Usage
I am using github as my blog source and save my posts in markdown format. Here is an example, [tech blog](https://github.com/superwalnut/tech-blog)
I created a sample post called "markdown.md".
Then I created github action that will automatically detect any .md files and convert the code blocks to gist embeded code and pushed these new files to the repository as well.
```
- name: Parse markdown
working-directory: ./Blogs
run: |
dotnet tool install --global MD-Gist
md-gist parse -t=${{secrets.GIST_TOKEN}}
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Add changes" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GIST_TOKEN }}
```It will create these files that you can publish directly in these blogging platforms
```
markdown-[Dev.to].md
markdown-[Hugo].md
markdown-[Jekyll].md
markdown-[Medium].md
```---
## Support
Reach out to me at one of the following places!
- [Follow me @ Github](https://github.com/superwalnut)
- [Twitter](https://twitter.com/superwalnuts)
- [![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z61I9HB)
---
## License
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)
- **[MIT license](http://opensource.org/licenses/mit-license.php)**
-------