From 8053b966f5a8a658d499aa3f93146f4659cd5487 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Tue, 6 Oct 2020 23:17:14 +0200 Subject: [PATCH] Add markdown transformation support. --- README.md | 2 +- config.sh.template | 1 + post.sh | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 87f97c6..e872615 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ CLI tool for submitting posts to WordPress through its REST API using curl. Install [Application Passwords](https://wordpress.org/plugins/application-passwords/) plugin and follow its installation steps (i.e. create a new passowrd for your user). ### Local shell -Make sure you have `curl` installed. +Make sure you have `curl` installed. If you want to enter text in markdown format, install `python-markdown2`. Create a config file `~/.config/wordpress-rest-curl/config.sh` from the `config.sh.template` file. diff --git a/config.sh.template b/config.sh.template index fe25069..ce44cc0 100755 --- a/config.sh.template +++ b/config.sh.template @@ -1,5 +1,6 @@ #!/bin/bash EDITOR=vim +TRANSFORM="" # '' / 'markdown' USER="" # WP user to create the post PASSWORD="" # application password generated for your WP user SERVER="" # server hostname, optionally with subdirectories diff --git a/post.sh b/post.sh index 98b070e..cc99be8 100755 --- a/post.sh +++ b/post.sh @@ -3,6 +3,7 @@ # config: EDITOR=vim +TRANSFORM="" # '' / 'markdown' USER="" # WP user to create the post PASSWORD="" # application password generated for your WP user SERVER="" # server hostname, optionally with subdirectories @@ -15,10 +16,18 @@ source ~/.config/wordpress-rest-curl/config.sh # let the user create the post $EDITOR $TMPFILE || exit 1 - -# load the file if it exists [[ -e $TMPFILE ]] || exit 1 -CONTENT=`cat $TMPFILE` + +# transformations +if [[ $TRANSFORM -eq "markdown" ]]; then + python >$TMPFILE.trans <