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 CSS in template (Read 26432 times)
Ian Greig
Full Member
*
Offline



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #15 - Dec 16th, 2010, 7:14am
 
Easier all round to see what is happening on the original .tbx, which I have posted.

Here's the trial document based on the 'Article Format' one Mark A put up, but with v. minor changes to the CSS, and the Markdown note placed directly within 'Internals'.

http://public.me.com/greiggy/Public/Tinderbox%20Article%20Format.tbx  (URL fixed by admin)

The Markdown note contains this:
Code:
$Text /usr/local/bin/Markdown.pl

^value(runCommand($Text(Markdown),$Text)^ 



Note that the Markdown Perl resource is called (cap M) Markdown and it is in /usr/local/bin/


Back to top
 
« Last Edit: Dec 16th, 2010, 7:30am by Mark Anderson »  

--IanG
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Using CSS in template
Reply #16 - Dec 16th, 2010, 8:06am
 
If the text above is exact, your computer is being asked to run the program $Text!

The first element on the command line is the program to run, in this case /use/local/Markdown.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #17 - Dec 16th, 2010, 8:10am
 
You have syntax error in your CSS. Yours:

body {
   font-family: garamond; georgia;
   font-size: 14px
   background: #999;
   color: #000;
}


Should be:

body {
   font-family: garamond, georgia;
   font-size: 14px;
   background: #999;
   color: #000;
}


The semi-colon at the end of font-size is best practice but the one above, in the font list is an error. See this tutorial on how you specify fonts in CSS, if you're unfamiliar (and wasn't just a stray typo!)

As to "Markdown" the contents of $Text should just be:
Code:
/usr/local/bin/Markdown.pl 


...and noting else. No line returns after the end of the above string - just the path to the MMD script.

Also you've failed to put the calls to MMD back into your "Article.html" & Section.html" templates. In each find (the one and only instance of) ^text^, and replace it with:

^value(runCommand($Text(Markdown),$Text)^

Just do a one-for-one replace - don't add any line breaks et., to the templates.

After the above the template, when exporting calls runCommand which in turns collects one of its parameters (the shell path to MMD script) from the $Text of the note "Markdown". This way if the MMB script changes all templates using MMD are updated via one edit. If instead we simply put the path to MMD into the runCommand - as in the original demo - is the script moves we must edit every template using MMD; here it's just two, but it could easily be many more. So although the method I've suggested may look more complex in the short term it will save you time in real world use.

Don't forget that if you drag the templates to another TBX (e.g. for a new project) you also need the Markdown note.  The latter must be a unique note name within any TBX. If for some reason it can't be, copy the $Path value for Markdown and in the templates alter the $Text(Markdown) to use the full path, e.g. $Text(/full/TB/internal/path to/Markdown) so TB looks at the correct note for the MMD path.
Back to top
 
 

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



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #18 - Dec 16th, 2010, 9:28am
 
Sorted the CSS typos;

Swapped the lines on the 'Markdown' note and deleted spurious returns (now two lines, closed up, correct order);

Reinstated calls to Markdown in 'Article.html' and 'Section.html' templates, one line for one line.

Now I get an impressive looking title page with grey border but nothing else...
Back to top
 
 

--IanG
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #19 - Dec 16th, 2010, 9:50am
 
Take a look at the HTML source. What do you see - compared to what you'd expect from the template? A description of the visual web page (or a screen grab of same) doesn't really tell us anything.
Back to top
 
« Last Edit: Dec 16th, 2010, 10:11am by Mark Anderson »  

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



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #20 - Dec 16th, 2010, 10:02am
 
The html source shows about 15-20 lines that correspond to what I see visually i.e. title, author name and contact
Back to top
 
 

--IanG
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #21 - Dec 16th, 2010, 10:10am
 
I'm guessing like article.html with no ^text^ and no included child text.

Re-reading the thread above I don't see any confirmation you've proved MMD script works on your Mac without TB being involved. If that first part doesn't work there's nothing TB can do to fix it. So I'll repeat that at this point you need to prove the script in the shell before trying to connect it up to TB or else it appears TB is to blame simply because it's the app you're trying to use. [I overlooked something in a different thread - sorry]
Back to top
 
« Last Edit: Dec 16th, 2010, 10:49am by Mark Anderson »  

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



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #22 - Dec 16th, 2010, 10:20am
 
#13 of thread "Html export difficulty"
Quote:
Yay! Markdown working fine now and the export is looking sensible.

Thanks for your help-- and patience.

Now I guess I should add some CSS to both (?) of the templates to get the typography a bit more under control...


So I know it works... just need to get TB, CSS and Markdown to play together.

BTW how would I run Markdown on this text in the terminal?
Back to top
 
 

--IanG
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #23 - Dec 16th, 2010, 10:48am
 
Ah, different thread - but sorry (I'll amend my last above).

Meanwhile, if Les' version works, copy the ^value(...etc... code that worked in his version and use that to replace the relevant code in your current version (the Markdown note will now be redundant). Likely it will work if the MMD script which worked before hasn't moved. If that works - I'd stick with and count your blessings.  Smiley

As to testing MMD in the shell - that's probably better asked in a shell-related or MMD-related forum. I can't take that aspect of the problem further simply because I'm no expert on the OS X shell! Anyone's welcome to step forward... Later - see post #37 for an MD test in Terminal.


Side note:
The reason the forum software isn't make URLs for your MobileMe URLs is because they include spaces. Replace each actual space in the path between the [url] tags with a %20 (i.e. " " -> "%20") and all should work. Or, simply avoid space in the first place and use underscores wherever you want a space. Basically URLs and spaces don't play nicely together. Meh, more techie trip-ups.
Back to top
 
« Last Edit: Dec 20th, 2010, 5:16am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #24 - Dec 16th, 2010, 12:35pm
 
Aha!. The above piqued my interest and I went back over your file. It proves the value in working on a real TBX. I found two logic error - easily missed when looking as text snippets. I've now tested and got it working and proved

The template code where the non-MMD version has  ^text^ goes should be:
^value(runCommand($Text(Markdown),$Text))^

Along the way we lost a ')' at the end of the line. In the Markdown note, before the note put "Perl " - that's the word Perl and a space without the quotes:

Perl /usr/bin/Markdown.pl

That works - using an edited version of you TBX. I then deleted the script at the /usr/bin/ path of my system and proved the process now failed, I then added the script to my home folder and  changed the Markdown note text to:

Perl ~/Markdown.pl

It works. So, my switchout method is validated too! The Perl part is probably not strictly necessary - as the shell should know to treat '.pl. scripts as Perl code, but there's no harm in being explicit.

Tip, for any later readers of this: put your Markdown.pl script where you like but don't place it at a path with any spaces in (unless you're expert with shell ops) or likely it won't work. Later: also see this test down-thread

I'll email @Ian the TBX
Back to top
 
« Last Edit: Dec 20th, 2010, 5:19am by Mark Anderson »  

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



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #25 - Dec 16th, 2010, 6:33pm
 
Have tried the revised trial "straight out of the tin". The Markdown note path was correct.

Still only seem to get a title and table of contents, no note or sub-note content
Back to top
 
 

--IanG
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #26 - Dec 17th, 2010, 4:15am
 
Since I emailed you, I've also solved the space in path problem. For an MMD script in ~/Test folder/, use a normal shell backslash escape** for paths, as in:

Perl ~/Test\ folder/Markdown.pl

As to your problem, try putting a copy of Markdown.pl in your home folder. Why, permissions are less likely to be an issue and because fiddling around with root account objects in /usr/bin/ isn't recommended for the non-Unix expert user. Stuff in your home folder automatically 'belongs' to your user account. So, with the script in your home folder, use this for the Markdown note:

Perl ~/Markdown.pl

If that works and you don't want the script clogging your home folder you could move the script to a sub-folder of your Documents, for instance to:

Perl ~/Documents/MMD/Markdown.pl

** For reasons I confess to not totally understand, in this context (within export code) only one backslash is required per space.  Normally in TB runCommand() - e.g. in a $Rule - two backslashes are required; one gets stripped in parsing within TB, the second within the shell.
Back to top
 
« Last Edit: Dec 20th, 2010, 5:23am by Mark Anderson »  

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



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #27 - Dec 17th, 2010, 9:13am
 
Thanks for that, I'll make the amends later.

I am inclined to agree about where to put the Markdown script. I posted earlier (on a previous thread) that I had misgivings about the usr/local/bin location. Personally, I don't believe that the run-of-the-mill Tinderbox user who is going to be essentially an ideas person -- strategy, research, teaching, writing, speaking etc -- should be expected to talk the language of Unix, or add things at this level.

Note quite sure I fully understand your point aboyut the backslash.

I think I'll try Library/Application Support/Tinderbox/Markdown/Markdown.pl as that seems to be in line with conventions and also I have more chance of remembering it!
Back to top
 
 

--IanG
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Using CSS in template
Reply #28 - Dec 17th, 2010, 9:51am
 
The backslash bit?  Just as URLs tend not to work if folder/filenames include spaces, the same goes for paths passed to the OS x (Unix) shell. In simple terms the software app receiving the /path thinks it ends at the first space. OK, that's the problem.

The shell - which in this context we use via runCommand  - has several ways of 'escaping' spaces; you precede the space with a backslash, or you put the whole path in quotes.  The former is the same logic by which '.' in a regex means 'any character' but '\.' means a a period character. Anyway, it transpires from testing that using our method above, where the path is stored in another note's text, the backslash  method works better that the quoting method. Thus $text of:

Perl ~/Test folder/Markdown.pl --> FAIL
Perl ~/Test\ folder/Markdown.pl --> SUCCESS

The only difference in the above is the '\' escaping the space it precedes.

[I'm sure that Les ) - in the original demo - is using /usr/bin/ for the path as he's an experienced coder, but for the resot us tinkering there might be playing with fire.]
Back to top
 
« Last Edit: Dec 17th, 2010, 9:53am by Mark Anderson »  

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



Posts: 74
Wokingham, UK
Re: Using CSS in template
Reply #29 - Dec 17th, 2010, 6:37pm
 
Perversely, I cannot seem to shake the problem of getting only a partial export.

I have made some changes, i.e. using the more recent MultiMarkdown script from Fletcher Penney and to overcome any issue of spaces, have installed it thus:
Code:
^value(runCommand($Text(MultiMarkdown),$Text))^ 



The new name of the script is used in article.html, section.html and the note containing the action is called MultiMarkdown.

Looking at the (limited) output, I think the MultiMarkdown is working fine. I think we need to look elsewhere for the reason the export is failing to complete.

Just to be belt-and-braces, my process is:

1. Select the top-most note "Article structure for html export"

2. From File menu, Export as html...

3. Dialog gives me folder to save in

This gives me the following exported output:

article.html (size 4kb)
css folder > article.css
js folder > article.js

Here is the current tbx file reflecting the above:
http://web.me.com/greiggy/Public/Tinderbox_Article_Format_3.tbx

Back to top
 
 

--IanG
  IP Logged
Pages: 1 2 3 
Send Topic Print