Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Tinderbox applications >> Using Marked with Tinderbox - a tutorial
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1347447038

Message started by Paul Walters on Sep 12th, 2012, 6:50am

Title: Using Marked with Tinderbox - a tutorial
Post by Paul Walters on Sep 12th, 2012, 6:50am

I find that a very helpful complement to Tinderbox's capabilities is using MultiMarkdown markup in note title and text, and exporting plain text to .md files.  I keep Marked open next to Tinderbox.  Marked previews the text and its export features will bridge the Tinderbox export into RTF (clipboard or file), PDF, HTML, or to a printer.  This is a particularly useful small workflow if I just need a quick extract of a few notes from Tinderbox -- I select the needed notes, or make an agent on the fly, and export them right off to Marked.

Here's a small tutorial that explains the basics of using Tinderbox + MultiMarkdown + Marked.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Derek Van Ittersum on Sep 12th, 2012, 9:22am

I've just been increasing my use of markdown for several reasons and this is timely and incredibly useful.  THanks!

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Derek Van Ittersum on Sep 12th, 2012, 9:25am

Have you experimented with using the runCommand to run markdown notes through markdown or multimarkdown scripts prior to export?  This has been described by Mark his blog. This was going to be my next step, but if others have found Marked a better solution, maybe I'll just stick with that ...

http://www.markbernstein.org/Aug0701/Tinderbox4usingMarkdown.html

Title: Re: Using Marked with Tinderbox - a tutorial
Post by David Bertenshaw on Sep 12th, 2012, 10:32am

It's been mentioned before on the forum, but you can also use MMD usefully in TBX with two cheap apps: QuickCursor and Byword (both £2.99 from the App Store).

QuickCursor lets you open your text in a compliant text editor with a shortcut key. Byword is a very nice MMD enabled text editor which makes writing and viewing MMD even easier. It doesn't allow you to do the batched processing discussed in the tutorial, though.

All I need to do when in a TBX note is cmd-opt-ctl-B (user-defined shortcut) and Byword opens, with preview available on cmd-opt-P. You can then export to RTF / Word / Latex or HTML, or simply update the tbx note with cmd-S, cmd-W.



I tend to use this for longish notes as the Byword editor is very nice: e.g. you can use the standard cmd-B and cmd-I shortcuts and it will both add the asterisks and show the effect on screen (not just in the preview). It also has support for automatic lists and indentation, typewriter scrolling and so on.

Regards

David


Title: Re: Using Marked with Tinderbox - a tutorial
Post by Paul Walters on Sep 12th, 2012, 10:46am

Good points, @Derek and @David.  The way I look at it, the runCommand approach works at a "micro" level, the QuickCursor/Byword approach generally works at a per-note level, and the approach I mentioned in my first posting works at a multiple-note or document level.  But none of these are mutually exclusive.  You could mix and match -- for example, fine tune markup with the runCommand technique, check it out with the QuickCursor/Byword technique, and make a final output with the Marked output.

But regardless of the workflow or method, the beauty of using Tinderbox and Markdown together, IMO, is you never lose any flexibility - you just gain.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on Sep 17th, 2012, 8:29am

@Paul, nice demo. (I'm now back on normal connection.) Nice choice of Clarify username too!

The Footnote support echoes a TB  feature request I put in some while back. If TB6 would let (deliberate use by more experienced) users create/target #-anchors in pages I've already figured out the rest of the moving parts to export (TB) footnotes inline with their parent page. The crux is a mechanism to allow users to control the formatted export of in-$Text links. Were it possible, I think a lot of new flexibility is ushered in.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on May 30th, 2013, 12:38am

I'm a new Tinderbox user.  Writing in byword/marked has been a part of my workflow for the past year.

Building on the prior posts, here is a potential workflow:

1.  Open a note in Byword via QuickCursor

2.  Open the Byword window in Marked.  I do this via an applescript which I can share if people are interested.  Or, you can drag the document icon, i.e. Tinderbox-(null) 004.txt on to the marked app.  

3. I then arrange my monitor with byword on the left half of the screen and marked on the right half of the screen.  Every time you hit save your progress is saved back into tinderbox and a preview is displayed in marked.  I love to do it this way so I can make sure that I'm using the correct syntax and I get instant feedback of what the exported page will look like.  

4. From marked, you can save the note into a pdf, rtf, html, etc. From marked you can use a custom CSS sheet so you can have your export look exactly how you want it.  I typically export it to a shared dropbox folder so it becomes a simple way to make a web page.  

5. Can someone explain the runCommand.  Where would you put the text that Mark writes about at the link Derek shared.

It sounds like using a runCommand would convert the markdown to html.  Is that right?  Could you embed CSS into the export?  

As I write this, I'm thinking that a script to do steps 1-3 would be very easy to make using another favorite app Keyboard Maestro.  Essentially, you could trigger (open in byword via QuickCursor, open in Marked, and arrange the monitors) in one keystroke.  When you are done editing/previewing, you would hit command+s and then command+w and you would be back to tinderbox.

Thanks,
Steve




Title: Re: Using Marked with Tinderbox - a tutorial
Post by pierfranco on May 30th, 2013, 1:42am

Hi Steve,

your workflow is very interesting.
I would be interested to have your applescript.
Do you think this could be adapted to a different markdown editor: that is MultiMarkdown Composer?

greetings

pierfranco

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on May 30th, 2013, 5:14am

Re 2Steve's question #5. Mark B's blog article (here, dated 6 Aug 2007) assumes you have Markdown already set up and Perl, etc. working correctly. Then, where in a template you might instert the  ^text^ export code, you would replace it with:

^value(runCommand("perl ~/..path..to../Markdown.pl",$Text))^

The ^value()^ export command simply inserts the result of an action code expression into the template output; it can also simply insert an attribute value rather than an expression.

^value($Text)^ equates to ^text(plain)^ rather than ^text^. Why? ^text^ is special in that $Text is parsed for elements needing HTML mark-up which is applied to the output. In the Markdown scenario above, we are using the ^value(expression)^ form, where the expression is a runCommand() action that calls out to use the Unix shell's Perl to run the Markdown script with $Text as the script's input.

Now, the runCommand() returns the output of the script - the text with HTML markup added - from the shell back into to Tinderbox. As this result is now also the result of the expression in ^value()^, the marked up text is inserted into the template output where the ^value()^ command is.

Thus if $Text of a note is 'This is **bold** text' (text colour/enclosing quotes for clarity only) then export variations work like this:

^text^                   -->                                                                              This is **bold** text
^value($Text)^          -->                                                                         This is **bold** text
^value(runCommand("perl ~/..path..to../Markdown.pl",$Text))^  --> This is <b>bold</b> text

Hopefully having explained the different in output, you can see that you would replace ^text^ with the ^value(run...)^ version in whatever template you are adapting.

Lastly, a little expectation management. In not expert in markdown but I can see that a markdown document expects things like footnotes to be in the same text document - i.e. in a TB context the $Text of the same source note. Markdown will not detect/convert Tinderbox internal links or web link in $Text. For those, you'd need to add appropriate link-defining Markdown code as well as/instead of the normal TB links. It may well be that if TB v6 supports Markdown, TB links may be detected created.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on May 30th, 2013, 11:14am

Mark,

Thanks for the detailed response. Unfortunately, I'm too new to tinderbox to understand how to do it.  I just

1- created a new template called markdown and pasted "^value(runCommand("perl ~/..path..to../Markdown.pl",$Text))^" into the template.

2- went to nakakoji view and tried to invoke the template, but nothing happened.

I probably need to build a better foundation before tackling it.

Pierfranco,

You could definitely use MultiMarkdown Composer.  Here is the applescript to open it it marked.  I didn't write it. . . I think I got it from the marked website.




Code:
-- Open in Marked
-- Attempts to open the currently-edited document in Marked for previewing
-- Based on ideas by Lri <https://gist.github.com/1077745>;
-- with contributions from Donald Curtis <https://github.com/milkypostman>;

---NV/nvALT configuation---------------------------------------------------
-- * Set NV/nvALT to store text files to disk
-- * Enter the full UNIX/POSIX path to your notes folder in nvNoteFolder
-- * Enter your default file extension (.txt,.md,etc.) in nvNoteExtension
-- It won't always work, but it will try. It's a temporary hack;
-- nvALT will soon have an AppleScript command to access the file directly.
property nvNoteFolder : "/Users/username/pathtonotes/" -- include trailing slash
property nvNoteExtension : ".md" -- include leading dot
---------------------------------------------------------------------------on run {}
tell application "System Events"
     set frontApp to (name of first process whose frontmost is true)
end tell

set f to false
set flist to {}

--Marked (if Marked is foreground, hide Marked and end script)
if frontApp is "Marked" then
     tell application "System Events" to set visible of process "Marked" to false
     return
     --Notational Velocity/nvALT
else if (frontApp is "Notational Velocity") or (frontApp is "nvALT") then
     try
           tell application "System Events" to tell process frontApp
                 -- Grab the text in the search field, hopefully this will be the filename
                 set p to value of text field 1 of group 1 of tool bar 1 of window 1
                 try -- look for it in nvNoteFolder with the nvNoteExtension suffix
                       set f to POSIX file (nvNoteFolder & p & nvNoteExtension) as alias
                 end try
                 if f is false then -- if we didn't get a bite...
                       try -- attempt with .txt
                             set f to POSIX file (nvNoteFolder & p & ".txt") as alias
                       end try
                 end if
                 if f is false then -- report the failure
                       set _res to display dialog "Couldn't open " & nvNoteFolder & p & nvNoteExtension & ". Check your property settings in the script." buttons {"OK"}
                       return
                 end if
           end tell
     on error errNO
           set _res to display dialog "Couldn't open " & nvNoteFolder & p & nvNoteExtension & ". Check your property settings in the script." buttons {"OK"}
           return
     end try
     --Finder (open selected file)
else if frontApp is "Finder" then
     tell application "Finder" to set flist to (get selection)
else if frontApp is "Emacs" then
     set emacsclient to false
     tell application "Finder"
           if exists POSIX file "/usr/local/bin/emacsclient" then
                 set emacsclient to "/usr/local/bin/emacsclient"
           end if
     end tell
     if emacsclient is not false then
           set f to do shell script emacsclient & " -e '(first (delete nil (mapcar (function buffer-file-name) (buffer-list))))' | sed 's/^\"//' | sed 's/\"$//'" as string
           if f is not "nil" then
                 set f to f as POSIX file as alias
           else
                 set f to false
           end if
     end if
     --Byword (open current document)
else if frontApp is "Byword" then
     tell application frontApp to set f to file of document of window 1 as alias
else if frontApp is "TextEdit" then
     tell application frontApp to set f to path of document of window 1 as POSIX file
     --Fallback (attempt "path of document 1" and see if current app responds)
else if frontApp is "Mou" then
     tell application "System Events"
           set f to text 17 thru -1 of (value of attribute "AXDocument" of first window of process "Mou" as text)
     end tell
else
     tell application "System Events"
           tell process frontApp
                 try
                       set isScriptable to has scripting terminology
                 on error
                       set isScriptable to false
                 end try
           end tell
     end tell
     if isScriptable then
           try
                 tell application frontApp to set f to POSIX file (path of document 1 of window 1) as alias
           end try
           if f is false then
                 try
                       tell application frontApp to set f to POSIX file (path of first document) as alias
                 end try
           end if
           if f is false then
                 try
                       tell application frontApp to set f to POSIX file (text 17 thru -1 of (get URL of document 1)) as alias -- BBEdit
                 end try
           end if
     end if
end if

if f is false and flist is not {} then
     tell application "Marked"
           activate
           repeat with afile in flist
                 open (afile as alias)
           end repeat
     end tell
else if f is not false then
     tell application "Marked"
           activate
           open f
     end tell
end if
end run

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on May 30th, 2013, 11:44am

Ah, you need to give the path you markdown on your Mac. In other words you need to 'customise' the red bit in this code:

^value(runCommand("perl ~/..path..to../Markdown.pl",$Text))^

For instance if, have "Markdown.pl" in my home folder on my Mac, the corrected version of the above would be:

^value(runCommand("perl ~/Markdown.pl",$Text))^

However, you must use the path on your Mac - which we can't see! Note too that the path is case sensitive. I presume the Markdown files come with some form of test and I'd do that to ensure Markdown works on your system before trying to fault-find via Tinderbox.

One last thought. Some apps that support Markdown might bundle the script in their own app. So, you might be using it but the script isn't anywhere you can find it so you might need to manually 'install' it. In simple terms ensure Markdown.pl is stored in a place you can reference in a path (and has the correct permissions. Get the Markdown files from http://daringfireball.net/projects/markdown/.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Paul Walters on May 30th, 2013, 1:11pm

I'll mention this because MultiMarkdown Composer was mentioned in the thread:  Markdown and MultiMarkdown are related but different.  MultiMarkdown is a superset of Markdown -- it has additional markup tags available that Markdown will not do anything with.  Whereas Markdown is available from John Gruber at Daring Fireball.  The binary for MultiMarkdown is provided by Fletcher Penney at

http://fletcherpenney.net/multimarkdown/download/

Once installed, multimarkdown.pl can be used with runCommand in the same manner as Markdown.

Penney is also the developer for MultiMarkdown Composer - a GUI interface to MultiMarkdown

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on May 30th, 2013, 1:44pm

Snowed under right now but I'll try to remember to add a page to aTbRef re use of MD and MMD and which basically summarises recent posts above. Saves re-learning later.

If a week goes by and nothing seen, someone give me a prod!

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on May 30th, 2013, 2:01pm

Thanks, Mark.  I'm going to try to implement this once I get a better understanding of TB.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on Jun 5th, 2014, 7:35pm

I have installed the new version of multimarkdown found here: http://fletcherpenney.net/multimarkdown/download/

Has anyone else tried to install it?  I'm trying to figure out where it gets installed with the mac installer.

I'll let you know if I get it figured out.

Steve

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on Jun 6th, 2014, 1:28am

Well, I can't believe it!  I slogged through it and figured it out!

Let me know if anyone needs a tutorial.

If you install multimarkdown and the support files, your link will be here:

/Volumes/Data/User/gwashington/Library/Application\ Support/MultiMarkdown/bin/mmd2XHTML.pl

Create an export template with this text:  

^value(runCommand("perl  /Volumes/Data/Users/sscott/Library/Application\ Support/MultiMarkdown/bin/mmd2XHTML.pl     ",$Text))^    

I can explain more, but I'm done after slogging through it.

Steve

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Graham Smith on Jun 6th, 2014, 2:29am

Steve,

I could be wrong, but Marked comes with latest version of MMD built in and MMD is updated when you update Marked.

Having said that the thread seemed to wander from using Marked, to using Markdown, so maybe what Marked does is irrelevant.

But just in case, I thought I would mention it.

Cheers,

Graham

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on Jun 6th, 2014, 10:30am

Hi Graham,

You are right the conversation wandered from marked, but it was always about how to best use markdown in tinderbox.  In order to use a runCommand, I installed separate version of multimarkdown.  I still use Marked , but using the runCommand has opened up greater flexibility and increased speed into my workflow.  Using Marked from Tinderbox requires a lot of manual work and manual saving of files in various locations.  As a teacher I am constantly updating files changing the dates of assignments, etc.  Using the runCommand, I can make a change and update several files simultaneously.  I think Marked is still very relevant.   The runCommand just opens up a new ways of doing things.

Steve

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Graham Smith on Jun 6th, 2014, 11:13am

Hello Steve,

Interesting what you say, as I am in a similar position but only just started with Tinderbox.

The problem with Marked is that is that you need to set it up to open the same file as TB is exporting, or if using another editor, saving. But I rather like this txt file as an intermediary which I can then save as PDF or Word etc from Marked. I preface the file with the date

2014-06-05-File name.pdf

so I have running archive of changes, so for example if I change a hand in date for an assignment, I know the version date when that change was made.

I'm actually fairly happy with this, but I will reread this thread properly on how to do the compiling directly from TB.

Having said that, as I am still at the stage of being rather confused with TB, maybe I should stick with what I am doing until my experience is a little more mature !

Cheers,

Graham

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on Jun 6th, 2014, 12:25pm

Hi Graham,

Count me on the side of those confused with tinderbox.  I'm slowly getting it!  I love Marked for the reasons you mention

I started a new thread over here http://www.eastgate.com/Tinderbox/forum//YaBB.pl?num=1402071759/0#0to talk about my workflow. .  

STeve

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Steve Scott on Jun 12th, 2014, 12:36am

Assuming you have multi markdown installed, here is an improved code snippet to use to export markdown to html:



Code:
^value(runCommand("perl  /usr/local/bin/mmd2XHTML.pl     ",$Text))^  



Title: Re: Using Marked with Tinderbox - a tutorial
Post by andreas grimm on Jan 28th, 2015, 7:01am

Important topic -- with lots of good suggestions so far. Thanks, everybody!

Steve Scott's improved code snippet did the trick on my end.

But now I struggle with German Umlaute (ä ü ö). Any ideas what I have to do in order to get them back?

Neither is markedApp able to display the German Umlaute once a txt- or md-file was exported out of Tinderbox.

Any ideas?

Cheers!

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on Jan 28th, 2015, 7:19am

I've now particular knowledge in this area but it sounds like encoding. TB's own export saves UTF-8 text which does support accented characters. But if you're shelling out to Perl, the trip there/back or the script itself my be altering encoding to a more narrow encoding.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by andreas grimm on Jan 28th, 2015, 8:35am

Exactly, Mark.

I'm using the runCommand script which calls up "mmd2XHTML.pl".

Is there a way -- maybe by using xlst or yaml -- to circumvent the possibility you're pointing at: that "the script itself my be altering encoding to a more narrow encoding."?

Best
a

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on Jan 28th, 2015, 11:48am

As I say, this isn't my area of expertise. Anyone else?

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Bernstein on Jan 28th, 2015, 2:17pm

Tinderbox exports utf-8; be sure Marked knows to expect utf-8.

(If problems persist, send me an email with (a) a sample file, and (b) an exported document showing the umlaut problem, and (c) pertinent details of versions of Tinderbox, Marked, etc.  

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Anderson on Jan 28th, 2015, 2:21pm


Quote:
Tinderbox exports UTF8; be sure Marked knows to expect uff-8.


Is that 'uff-8' or a typo for 'utf-8'?

Title: Re: Using Marked with Tinderbox - a tutorial
Post by andreas grimm on Jan 28th, 2015, 7:09pm

Dear Mark Bernstein.

I just sent you an eMail. I attached the requested files.

Loved to hear back from you.

Cheers!


Title: Re: Using Marked with Tinderbox - a tutorial
Post by Mark Bernstein on Jan 29th, 2015, 2:36pm

The other thing to check in this workflow is that you've turned off $HTMLEntities.  For example, Tinderbox normally converts an "&" in the text to "&amp;", and a ü to &uuml; -- you don't want that for Markdown.

Title: Re: Using Marked with Tinderbox - a tutorial
Post by andreas grimm on Apr 17th, 2015, 2:47pm

Question -- just for the sake of clarification:

Using "mmd2XHTML.pl" in runCommand works fine. Using "MultiMarkdown.pl", however, seems to work just fine, as well.

Anyone here who can shed some light on significant differences one might not sense at first glance.

Ideas?

Cheers!

Title: Re: Using Marked with Tinderbox - a tutorial
Post by Paul Walters on Jul 10th, 2015, 9:07pm

I've updated the long-ago tutorial I posted that started this thread with a new tutorial for using Tinderbox Six with Marked 2.

The tutorial is located here.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.