Export open-format so I can slice-n-dice myself

Howdy, I’m new to Scrivener and trying to figure out if it will suit my needs. Let me describe my use case (which may be unusual), and the features I think would help with it, and perhaps I’ll learn that Scrivener already has what I need :slight_smile:.

I have written a book draft in HTML, using a text editor, with a separate file for each chapter. Needless to say, this is a pain, and exactly the sort of thing Scrivener seems to be designed to make easier. It’s intimidating for me to revise the book, because I am staring at HTML, in these huge sections, it’s hard to rearrange, etc. It sucks! Having little RTF Scrivenings in a nice GUI seems like it would be a huge improvement. It’s a bummer to lose my placements of pictures when importing, but maybe it’s dumb for me to have them in the first place (essentially it’s like typesetting my manuscript while it’s a draft).

Because it’s written in HTML, I have kept my book draft online, and it has benefited enormously from user feedback and search engine traffic because of this. I use a script I wrote which adds headers, footers, and TOCs, and links everything together (so each section links to the next and previous sections). Here’s an example chapter:

http://seastead.org/commented/paper/ocean.html

It is that latter functionality that I am worried about if I transfer my book into Scrivener. I’m not asking for Scrivener to do it for me - it would be a really rad feature, but a pretty big one. But I’m wondering if Scrivener could export:

a) The TOC, meaning the hierarchical contents of the Draft folder
b) Each scrivening, as RTF, or (ideally) processed through any of the standard export methods.

That way I could use my own scripts to build a nice webpage version. Essentially, having such an export format would allow technical folks to write scripts to compile the book their own way.

I know very little about MMD, so perhaps this is something I could replicate with it? Or by parsing its LaTeX output? If the compiled book includes enough information to reproduce the hierarchy - perhaps in HTML comments or something, then I could derive the TOC myself. Say, an HTML comment indicating each folder start and scrivening start. That seems like it would be pretty easy from Keith’s end.

Anyway, thanks for listening to my ramblings, and I hope there is a way to do what I want w/ your program, b/c it would sure be easier than using emacs and python scripts and web browsers to do my writing!

Having looked into MMD more thoroughly, it looks like it will do everything I need. Yay! (And sorry for not researching it first)

Now I just need to figure out how to convert my HTML to MMD format for importing…

You are definitely a candidate for MMD! You’ll be quite pleased with the quality of XHTML it generates; very clean and human readable. To see an example of how a TOC can be generated, go to the FAQ and find the download link. I’m using MMD to generate the BBCode for the FAQ. The XSLT file for doing that is included in the downloadable archive. There might be a better way of doing it, but I’m just sticking a non-existent tag in, , and then having the XSLT go through all of the header elements and generate a list out of them. It would simple to adopt a similar technique for your own uses. You would just write an XSLT that would alter the HTML a bit.

As for converting XHTML to MMD, waste no time doing it manually! Download the HumaneText.service. It will show up as a Service in the OS X menus. It expects properly formed XHTML, that is the only catch. If this is a problem, use Tidy to convert it to XHTML, first. It’s free and it will clean up any mistakes in the code, too.

As you probably know by now, MMD is actually a set of scripts which extend the basic Markdown syntax, allowing a wider export capability. LaTeX output is optional. You’d be doing much better to just export straight to HTML from Scrivener. The only reason you’d want to use the LaTeX exporter is if you write your own XSLT as described above. Even if it doesn’t generate an actual LaTeX file, that is the only option that allows you to use your own XSLT. Kind of unintuitive, but also pretty niche.

One other thing that will save you a lot of time. When you convert your HTML files to MMD, note Scrivener’s MultiMarkdown importer in the File menu. This will take the header structure and convert it to Binder outliner structure, cutting everything up into sections for you, and naming the sections according to the heading.

When using Scrivener to author MMD files, you needn’t worry about manually titling. It will handle all of that on export.

Awesome, thanks for the info. I found a python script to convert all my HTML to MarkDown, and imported it into Scrivener. I also converted it all back to HTML to check that it looks right. Tables are messed up, and images that linked to larger versions look weird (because the links are references), but all in all it looks pretty good!

I’ll check out the XSLT for making TOCs, one thing I want is a TOC for the whole document, and the other is a TOC for each chapter and each section. But if the XHTML is really nice, that shouldn’t be too hard.

I will check out the MMD importer.

Since tables are a MMD, and not a Markdown, feature, I suspect that the HTML->Markdown tools will not support them.

It’s possible to write (or update) and XSLT file that converts XHTML back into Markdown text. This would allow you to include table support. I suppose one could also write an XSLT that converted tables into MMD, but left the rest of the document unmodified, and then use a generic text->MD tool. There are possibilities…

Tables are rare enough that I’ll just copy and paste the HTML in by hand. Since MMD allows raw HTML, it’s not really a problem.