Giter Club home page Giter Club logo

md-publisher's Introduction

Go

md-publisher

md-publisher Logo

md-publisher-logo by Andre Mueller is licensed under CC BY 4.0

The md-publisher golang tool shall simplify the process of publishing local HTML (and using pandoc Markdown) files to https://medium.com.

Local images are first uploaded to medium and then the article is published as draft.

Installation

Install the md-publisher tool with

go install github.com/andremueller/md-publisher@latest

Go will install the binary to the bin folder in your Go directory (usually something like $HOME/go/bin).

md-publisher requires tool an integration token. Hereto, you need a medium.com account and must have published at least one article. Then you can simply create a token on your settings page https://medium.com/me/settings. Create a TOML configuration file in $HOME/.config/md-publisher/md-publisher.conf with the following content:

# md-publisher.conf configuration file shall be found in
# $HOME/.config/md-publisher/md-publisher.conf

# Settings for medium.com
# Create an integration token in your medium.com account on your settings
# page https://medium.com/me/settings and enter it here
MediumAccessToken="YOUR_ACCESS_TOKEN"

# Set this true if you never want to upload your images.
NoImages="false"

Running

When using markdown files you could use pandoc for translating that into html (see examples/run.sh).

After that you should be able to upload a local HTML file with

md-publisher publish my_file.html

For further options call

./md-publisher help

NAME:
   md-publisher - Publishes an articles to medium.com

USAGE:
   md-publisher [global options] command [command options] [arguments...]

COMMANDS:
   publish  publish the given article
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --log-level value, -L value  set logging level to (5 = debug, 4 = info, 3 = warn, 2 = error, 1 = fatal (default: 5)
   --config value, -c value     md-publisher config file (default: "/Users/muellera/.config/md-publisher/md-publisher.conf")
   --help, -h                   show help (default: false)
NAME:
   md-publisher publish - publish the given article

USAGE:
   md-publisher publish [command options] [arguments...]

OPTIONS:
   --no-images           Do not upload images (default: false)

Then you should find the newly article within your drafts including local images.

Dependencies

Dependency License
github.com/urfave/cli/v2 MIT License
github.com/sirupsen/logrus MIT License
github.com/Medium/medium-sdk-go Apache License Version 2.0
github.com/PuerkitoBio/goquery BSD 3 Clause License
github.com/yuin/goldmark MIT License
github.com/litao91/goldmark-mathjax MIT License

License

MIT License

The project is currently in an experimental state. So please don't blame me if something is not working. However, you are welcome to contribute to this project.

HTML Features

  • Uploading local images in <img> tags
  • Setting the title to head title
  • Settings the medium tags to meta keywords
<head>
   <title>My title</title>
   <meta name="keywords" content="my tag 1, my tag 2" />
</head>

For an example file see example/demo_article.html.

Markdown

It is recommended to use https://pandoc.org for transforming Markdown files to html which could then be uploaded with md-publisher.

Important is especially the YAML meta header which allows the specify title, tags (called keywords for compatibility), BibTeX reference file, and many more attributes.

See https://pandoc.org/MANUAL.html#extension-yaml_metadata_block for all possible meta tags.

For an example file see data/demo_article.md.

A script for converting the data/demo_article.md to data/demo_article.html is here: pandoc.sh

For the pandoc.sh script the following tools must be in the search path of your shell

  • pandoc
  • pandoc-crossref
  • pandoc-citeproc

Hereto, please look the installation instructions on https://pandoc.org.

Current working features:

  • bibliography
  • images
  • tables
  • equations
  • references to figures, equations, tables

If you like you can use my pandoc Docker container for this step as well.

Known Issues

  • Nested lists do not work. However, medium.com seems to be the probleme here.

md-publisher's People

Contributors

andremueller avatar dependabot[bot] avatar dbast avatar

Stargazers

 avatar Claudio Hermida avatar tybik avatar  avatar Alan Szmyt avatar Josephood7 avatar  avatar Russell Warner avatar  avatar Wayne S. avatar Joonbeom Kwon avatar tlopplot avatar Kunlei Lian avatar 不游 avatar Juan Ochoa avatar  avatar Zhengyi Shen avatar  avatar Matt McCormick avatar Ozohu avatar Samuel avatar Hassan Salmani avatar Mauro Soria avatar Jie Lyu avatar Haifeng Jin avatar Le Minh Tri avatar LCamel avatar Dennis Grobe avatar Zack avatar FilipeA avatar Max Cobb avatar  avatar Joseph Kato avatar  avatar Vale-Tech avatar Nirmal avatar Sandeep Kumar Gangarapu avatar

Watchers

 avatar James Cloos avatar Russell Warner avatar

md-publisher's Issues

Why not to post markdown files directly?

Medium API supported creating posts directly from markdowns: https://github.com/Medium/medium-api-docs?tab=readme-ov-file#creating-a-post

Why not to implement an option which will allow posting markdown files?
This way MD->HTML conversion by pandoc can be avoided. Also, from Medium side, their HTML->MD importer will also not be used. And this importer is the trouble-maker, which creates all kind of troubles with nested lists etc.

The only difficulty would be to extract the list of image links directly from markdown. But even if there is no ready-made parsers available for that, it is relatively easy just to find all patterns like ![]().

Unable to Install/ Build Package

When I try to install md-publisher using go get i get error saying that this command is only supported in modules instead use the go install command when I do go install github.com/andremueller/md-publisher@latest I can see packages getting download but after its done if I type md-publisher or md-publisher help I get command not found.

I tried to clone the repository and from within the repository run go get github.com/andremueller/md-publisher it again shows some packages getting download but when I list the files in the directory I do not see any binary file. Tried running the build.sh command as well but getting the same result.

I have tried the same from a Docker Container as well as from a Ubuntu VM but getting the same issue. Can you help me I am not sure what am I going wrong using go version 1.19.4

Cannot get medium user: Access token required

Hi Andre,

thanks a lot for your efforts and the md-publisher - it's exactly what I was looking for. Unfortunately I am getting an error

FATA[0000] Cannot get medium user: medium: An access token is required. (6000) on both Windows an MacOS even though I provided a medium Access token. I've tried it with the Access token defined in a config file and via the command line. Is it just me having difficulties handling the program or is there a problem with the tool?

Best regards
Benedikt

[FR] support for inline formula

The content wrapped by $ and $$ is rendered as an image, making it impossible to distinguish between in-line and block-level formulas.
I don't know if the medium platform itself supports in-line formulas. If so, I look forward to adding this feature.

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.