« MBS FileMaker Plugin,… | Home | FileMaker Magazin - M… »

Using Markdown Javascript converter in FileMaker

Today I created a new example for using Javascript and Webviewer in FileMaker to convert from markdown to HTML.

Actually the script is not very complicated with only a few script steps. The html file we load in the webviewer, provides the required javascript in one Convert function. Input and output is done with two invisible text areas in a form. The complete webviewer is just white and not visible to user. The script looks like this:

Set Variable [$r; Value:MBS( "WebView.SetFormTextAreaValue" ; "MarkDownWebViewer"; "formtest"; "input"; WebViewer MarkDown::Input; 1 )]
Set Variable [$r; Value:MBS( "WebView.RunJavaScript" ; "HTMLEditor"; "try { Convert(); } catch (e) { alert(e); }" )]
Set Field [WebViewer MarkDown::Output; MBS( "WebView.GetFormTextAreaValue" ; "MarkDownWebViewer"; "formtest"; "output"; 1 )]
Set Web Viewer [Object Name: "PreviewWebviewer"; URL: "data:text/html," & WebViewer MarkDown::Output]

As you see, we just fill in the form field with the markdown text. Next line we run the Convert() command. Wrapped in a try/catch to catch any javascript error and show it in an alert. Next we query the result from the second form field and display it in a text field in FileMaker. Finally we show the html in a webviewer as preview. Claris FileMaker Plugin
30 09 15 - 00:07