tag:support.markedapp.com,2011-09-11:/discussions/suggestions/26-automatic-toc-generated-for-htmlMarked: Discussion 2017-08-14T19:50:41Ztag:support.markedapp.com,2011-09-11:Comment/108416462011-10-24T19:03:49Z2011-10-24T19:07:13Zautomatic TOC generated for HTML<div><p>This has been requested a couple of times. My main consideration
is that the current TOC uses jQuery, and that means having to
include not only the TOC javascript, but the entire jQuery library
as well. The extra CSS is minimal, it's just the addition of the
jQuery library that worries me.</p>
<p>Open question: would an additional 100k on the output file be an
issue if it was specifically requested by the user?</p>
<p>Alternatively, I could export a directory structure with the
necessary files separately to avoid confusion. I like the idea of
everything being self-contained in a single, ready-to-publish file,
but it's an option.</p>
<p><strong>Update:</strong> I take it back. I forgot I switched to
a non-jQuery TOC generation method. I can include the TOC without
adding more than 8k to the whole thing. I'll plan on adding that as
an option for 1.3.2 (1.3.1 is in review right now).</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/108416462011-10-24T19:14:08Z2011-10-24T19:14:10Zautomatic TOC generated for HTML<div><p>100k isn't much, so it wouldn't be a problem. But only 8k
additional is a no brainer. Wow, let's rock this TOC thing! Many
thanks for including with 1.3.2. It will be a major enhancement to
Marked (at least for some of us).</p>
<p>With the addition of easy multiple custom styles, and other
enhancements, it's hard to envision using anything other than
Marked these days as my "page layout" app of choice.</p></div>Mathew tag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T11:21:11Z2011-10-25T11:21:12Zautomatic TOC generated for HTML<div><p>In my excitement about TOC generation, I forgot to ask a
critical question regarding placement. Will it be easy to designate
where the TOC is located? (e.g typically I don't want it at the
very top of a page, but below H1 and some short introductory
text).</p>
<p>Alternatively if there's no way to indicate where the automatic
TOC is located, will it be very easy to change placement with the
resulting HTML (I'm assuming yes)</p></div>Mathewtag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T13:02:21Z2011-10-25T13:02:21Zautomatic TOC generated for HTML<div><p>There won't be any way to specify it, but placing it within the
HTML is as easy as moving a div around. I'll make sure it's clearly
commented in the source.</p>
<p>I was planning to have it function just like it does in the
preview, where it hides on the side, but it sounds like you want to
have it in the document itself. That would take some extra styling,
but I can come up with something.</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T13:09:17Z2011-10-25T13:09:18Zautomatic TOC generated for HTML<div><p>Yes, I would envision them being in the document itself. Hmm . .
. I wonder how a TOC off to the side would work on a web page:
would there be some indicator to a user that there was a "hidden"
panel of links to access?</p>
<p>Currently you have to be "in the know" to use the TOC within
Marked (there's no visual indicator that I can see). Not a problem
as each user learns about this when they buy the program. But for
the web, with many diverse users, there would need to be—it
seems to me—some clear visual indication that a TOC was
available off to the side.</p></div>Mathewtag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T14:37:40Z2011-10-25T14:37:40Zautomatic TOC generated for HTML<div><p>I "hid" it because I didn't want it to be obtrusive in any way,
but I can certainly make it more obvious either just in the HTML
export or in HTML <em>and</em> the preview window. I can also
easily apply a stylesheet that allows exported HTML and print to
include the TOC inline in the document, which might be a nice
option on export. Adding both options to the list for an upcoming
version.</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T15:05:58Z2011-10-25T15:06:00Zautomatic TOC generated for HTML<div><p>Yes, in Marked having the TOC hidden works very well. Just needs
to be more obvious to a wider audience when in HTML. Thanks so much
for adding both of these options!</p></div>Mathewtag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T15:12:50Z2011-10-25T15:12:53Zautomatic TOC generated for HTML<div><p>BTW, I don't think seeing the complete TOC has to be obvious.
But if there were a simple icon, or text link, off to the side
indicating there was something to click on then that would probably
be enough. It's very elegant how the current TOC as currently
implemented in Marked slides out. That same behavior would still be
nice to have as an option.</p></div>Mathewtag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T15:19:13Z2011-10-25T15:19:13Zautomatic TOC generated for HTML<div><p>This will take some thinking, but I'll plan something in
soon.</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/108416462011-10-25T15:25:01Z2011-10-25T15:25:02Zautomatic TOC generated for HTML<div><p>Brett: Many thanks! I know it takes some extra work about how
best to implement this. I don't have obvious practical suggestions
to make to solve this. In practice, I've just found that if it's
not "obvious" on a web page then it won't get noticed or used. (I
think your visitors overall are quite different, more geeky.)</p></div>Mathewtag:support.markedapp.com,2011-09-11:Comment/108416462013-06-06T15:46:18Z2013-06-06T15:46:18Zautomatic TOC generated for HTML<div><p>You could use <a href="http://code.google.com/p/h5o/">h5o, the
HTML5 outliner</a> It is less than 3KB.</p>
<p>I would like to have a standard TOC in the exported HTML file,
right after the H1 (if there is one H1 at the top, and only one, I
guess), with no special styling whatsoever nor hide/show or fancy
animation effects.</p></div>chocolate.cameratag:support.markedapp.com,2011-09-11:Comment/108416462017-08-14T12:42:20Z2017-08-14T12:42:21Zautomatic TOC generated for HTML<div><p>I found out that it's still not possible to export a PDF with a working table of contents from Marked :( What's the suggested way to get around that today? What command line tool should I use to export an HTML document to a PDF with a working outline and table of contents?</p></div>Roel Van Gilstag:support.markedapp.com,2011-09-11:Comment/108416462017-08-14T14:52:38Z2017-08-14T14:52:38Zautomatic TOC generated for HTML<div><p>Pandoc can do it (<a href="http://pandoc.org/">http://pandoc.org/</a>). There's a tool called wkpdf that<br>
used a custom version of WebKit to do it, but I think development on it<br>
stopped and I'm not sure it works with newer versions of macOS.</p>
<p>If you haven't used Pandoc before, it can take a bit of experimentation<br>
to get the command line options right. Here's a helpful link:<br>
<a href="http://www.mscharhag.com/software-development/pandoc-markdown-to-pdf">http://www.mscharhag.com/software-development/pandoc-markdown-to-pdf</a></p>
<p>-Brett</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/108416462017-08-14T14:59:16Z2017-08-14T14:59:17Zautomatic TOC generated for HTML<div><p>Thanks, Brett. I got the job done using wkhtmltopdf, although it has its own quirks (font-size should be set to 400% in CSS when using it on a Retina MacBook, for some reason).</p>
<p>Thanks for the info on Pandora. I'll look into that!</p>
<p>BTW: as I understand, it's Apple's fault that the webkit PDF renderer doesn't create a TOC or clickable links. Will they ever fix that, you think?</p></div>Roel Van Gilstag:support.markedapp.com,2011-09-11:Comment/108416462017-08-14T15:27:51Z2017-08-14T15:27:51Zautomatic TOC generated for HTML<div><p>The issue seems to be fixed in the latest versions of Safari, but the<br>
SDK hasn't been updated to allow apps built with WebKit to take<br>
advantage of the bugfix. I'm hoping to see it come down the line soon.</p>
<p>-Brett</p></div>Bretttag:support.markedapp.com,2011-09-11:Comment/108416462017-08-14T19:50:38Z2017-08-14T19:50:41Zautomatic TOC generated for HTML<div><p>Thanks, Brett.</p>
<p>I just tried to print an exported HTML document (with TOC) from Safari (not even the Technology Preview) and the PDF indeed comes out just fine (with internal anchors that actually work). That's easier using a command line tool.</p>
<p>The one thing still missing is the built-in table of contents (View → Table of Contents in Preview.app). When delivering a document to clients, I find it not really acceptable to ship it without this TOC (it's a very convenient way to navigate large PDF files). Let's hope Apple adds this support to a future version of the SDK too. Although, wkhtmltopdf does it… so maybe it's possible somehow?</p>
<p>For now, I think I'll just stick with wkhtmltopdf and experiment some more with all the command line options it offers.</p></div>Roel Van Gils