Example of how to convert articles of a WordPress blog to static markdown.
wpstatic is used to read in all content of a WordPress blog and generate an HTML file of all articles held in the WP database.
- Download/Clone wpstatic
- Upload to server hosting WP blog within the same directory that contains wp-config.php
- Run: '$ ./wpstatic'
- I went into WP admin console and changed the post count on page to 1000, allowing for all posts to be accessed in a single request from wpstatic
- I had to change line 121 in wpstatic to work on the system that hosted my WP blog. I changed:
if [[ "$tablename" =~ $tb_prefix ]]; thento
if [[ "$tablename" = ~$tb_prefix ]]; th
PhantomJS is used to read in the full output HTML file from wpstatic and split out single articles.
Assume using virutalenvwrapper for python projects.
NodeJS, NPM & Grunt
Uses grunt-markdown-blog to generate HTML articles based on converted markdown.
Articles to Markdown
| using html2text.
- Setup virtualenv and install requirements.
$ mkvirtualenv blog -r requirements.txt --system-site-packages
- Start local server
$ python -m SimpleHTTPServer 8080
- Load output of wpstatic into phantomjs and output to singular files organized by title/date
$ phantomjs post-parser.js
- Convert single posts to markdown using html2text
$ python blog-to-markdown.py
Markdown to Articles
| using grunt-markdown-blog task.
Notes grunt-markdown-blog uses Underscore templates.