html - Recursive directory parsing with Pandoc on Mac -


i found question had answer question of performing batch conversions pandoc, doesn't answer question of how make recursive. stipulate front i'm not programmer, i'm seeking on here.

the pandoc documentation slim on details regarding passing batches of files executable, , based on script looks pandoc not capable of parsing more single file @ time. script below works fine in mac os x, processes files in local directory , outputs results in same place.

find . -name \*.md -type f -exec pandoc -o {}.txt {} \;

i used following code of result hoping for:

find . -name \*.html -type f -exec pandoc -o {}.markdown {} \;

this simple script, run using pandoc installed on mac os x 10.7.4 converts matching files in directory run in markdown , saves them in same directory. example, if had file named apps.html, convert file apps.html.markdown in same directory source files.

while i'm pleased makes conversion, , it's fast, need process files located in 1 directory , put markdown versions in set of mirrored directories editing. ultimately, these directories in github repositories. 1 branch editing while branch production/publishing. in addition, simple script retaining original extension , appending new extension it. if convert again, add html extension after markdown extension, , file size grow , grow.

technically, need able parse 1 branches directory , sync production one, when changed, removed, , new content verified correct, can run commits publish changes. looks find command can handle of this, have no clue how configure it, after reading mac os x , ubuntu man pages.

any kind words of wisdom appreciated.

tc

create following makefile:

txtdir=sources htmls=$(wildcard *.html) mds=$(patsubst %.html,$(txtdir)/%.markdown, $(htmls))  .phony :  : $(mds)  $(txtdir) :     mkdir $(txtdir)  $(txtdir)/%.markdown : %.html $(txtdir)     pandoc -f html -t markdown -s $< -o $@ 

(note: indented lines must begin tab -- may not come through in above, since markdown strips out tabs.)

then need type 'make', , run pandoc on every file .html extension in working directory, producing markdown version in 'sources'. advantage of method on using 'find' run pandoc on file has changed since last run.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -