0

Is there an external (plugin) which wraps the pandoc http://johnmacfarlane.net/pandoc/ document converter? I would like to run the content of a LiveCode field through pandoc and get the result back in a LiveCode variable/field. A prominent use of pandoc is to convert markdown to HTML. Maybe there is such a converter implemented in LiveCode?

A list of markdown implementations: https://github.com/markdown/markdown.github.com/wiki/Implementations

z--
  • 2,186
  • 17
  • 33

2 Answers2

1

It's unclear from your question if you actually only need markdown to html. If that's all you need then check out https://github.com/montegoulding/mergMarkdown

Monte Goulding
  • 2,380
  • 1
  • 21
  • 25
0

Trevor DeVore Has a GitHub repository of a markdown library at https://gist.github.com/trevordevore/5090459

As pandoc is a command line utility you should be able to call it via:

shell("pandoc -f markdown -t html yourinputfile")

And if you want to wrap that into a function it should be possible to do something like

function markDown2HTML pMarkDown pFromFormat pToFormat
   put specialFolderPath("temporary") & "/pandocConvert" & the seconds into tTmpFile
   put pMarkdown into URL "file:" & tTempFile
   put shell("pandoc -f" && pFromFormat && "-t" && pToFormat" && tTempFile) into tHTML
   delete file tTempFile
   return tHTML
end markDown2HTML

Note: This is written out of my head and not tested with an actual pandoc installation.

hliljegren
  • 426
  • 3
  • 9
  • 1
    A note from the shell function doc: "If you use a file path in the shell command on a Windows system, the file path must be in Windows form, not the Unix-style file paths that LiveCode uses internally." – hliljegren May 27 '13 at 12:59
  • Trevor DeVor uses as input parameter a styledText array. What is this? The User's Guide does not comment on that. – z-- May 27 '13 at 15:56
  • 1
    styledText is a property that was added to fields relatively recently. 5.5 I believe. Look in the dictionary that comes with LiveCode (under Help menu). styledText is an array that represents the text in the field. It is a great format for converting to other formats. – Trevor DeVore May 28 '13 at 03:07