Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1 2 3 
Send Topic Print
Using Marked with Tinderbox - a tutorial (Read 27540 times)
Paul Walters
Full Member
*
Offline



Posts: 267

Using Marked with Tinderbox - a tutorial
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.
Back to top
 
 
  IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Using Marked with Tinderbox - a tutorial
Reply #1 - 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!
Back to top
 
 
  IP Logged
Derek Van Ittersum
Full Member
*
Offline



Posts: 168

Re: Using Marked with Tinderbox - a tutorial
Reply #2 - 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
Back to top
 
 
  IP Logged
David Bertenshaw
Full Member
*
Offline



Posts: 182

Re: Using Marked with Tinderbox - a tutorial
Reply #3 - 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

Back to top
 
« Last Edit: Sep 12th, 2012, 10:33am by David Bertenshaw »  
  IP Logged
Paul Walters
Full Member
*
Offline



Posts: 267

Re: Using Marked with Tinderbox - a tutorial
Reply #4 - 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.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using Marked with Tinderbox - a tutorial
Reply #5 - 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.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: Using Marked with Tinderbox - a tutorial
Reply #6 - 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



Back to top
 
 
  IP Logged
pierfranco
Full Member
*
Offline



Posts: 8

Re: Using Marked with Tinderbox - a tutorial
Reply #7 - 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
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using Marked with Tinderbox - a tutorial
Reply #8 - 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.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: Using Marked with Tinderbox - a tutorial
Reply #9 - 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 

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using Marked with Tinderbox - a tutorial
Reply #10 - 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/.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Paul Walters
Full Member
*
Offline



Posts: 267

Re: Using Marked with Tinderbox - a tutorial
Reply #11 - 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
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using Marked with Tinderbox - a tutorial
Reply #12 - 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!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: Using Marked with Tinderbox - a tutorial
Reply #13 - May 30th, 2013, 2:01pm
 
Thanks, Mark.  I'm going to try to implement this once I get a better understanding of TB.
Back to top
 
 
  IP Logged
Steve Scott
Full Member
*
Offline



Posts: 169

Re: Using Marked with Tinderbox - a tutorial
Reply #14 - 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
Back to top
 
« Last Edit: Jun 5th, 2014, 7:56pm by Steve Scott »  
  IP Logged
Pages: 1 2 3 
Send Topic Print