Export Binder--Not Binder Files--As Text File

I would like to publish my project as a static web page using mdbook.
To accomplish this, I need a directory listing of the files in the project.

Can binder names of files be exported as a text file? I could take a screenshot of the binder and retype everything, but I’d rather not do that.

if I highlight [Uploading: Screen Shot 2021-10-14],

Screen Shot 2021-10-14 at 1.13.38 PM
there appears a list of the binder documents in the main viewer, but copying the list and pasting into a text editor doesn’t work. I tried several times and only the word “Section” was copied over.

Ctrl+A highlights everything in the binder, but Ctrl-V doesn’t bring these over.

Older query not relevant because my query has nothing to do with OPML.

Export hierarchical outline of binder?

I have no idea how you got that result from the outliner, you must have an unusual setup there.

But at any rate that would not be the best way to just get a list of only titles, since copying from the outliner/corkboard also copies the synopsis. Just copy from the Binder. Easy. When pasted into Scrivener you get a link list, but anywhere else will just be a text list.

I figured it out.

You can Ctrl-A the Binder.

But you have to Edit=>Copy Special=>Copy Documents as Structured Link List

Then, open an editor.

Then Control+v will give you the desired text file.

(I didn’t know about the “copy special/structured link list” requirement.

You can use either Edit ▸ Copy or the second command. Either will produce the same effect if you paste into a plain-text editor naturally, but into a rich text editor one will be indented by hierarchical level in the binder and the other will be flat.

Strange that Ctrl+a, followed by Ctrl+v did not work.
The hierarchical paste would be useful, but the mdbook index file has to be plain text. So the minute I converted the file back to txt the hierarchy would be gone.

FWIW, I can’t think of another way of putting this together without Scrivener.

To take that very literally, that doesn’t seem strange to me. Merely selecting something wouldn’t copy it (at least, not on a Mac, Linux does work that way in some contexts). You still have to tell the software you want to Copy, with ⌘C, or the menu command I mentioned.

The hierarchical paste would be useful, but the mdbook index file has to be plain text. So the minute I converted the file back to txt the hierarchy would be gone.

Maybe try using compile, with the setting to TXT, and use the “Enumerated Outline” Format, with everything assigned to the basic “Outline Item” Layout (which adds no numbering). That format is set up to convert indents to whitespace, so the result is text compatible.

That may not actually produce a result you want though, if the system is Markdown-based. Whitespace indenting invokes code blocks in most cases.

I assume that I executed the intermediate copy command (Cmd=>c) but it’s possible that I did not. I had to come back to this issue because I needed to have a hardcopy with the hierarchy. First, after manually selecting the binder, the standard “copy” option was greyed out. Copy special was present; copying both “as ToC” and “as Structured Link List” on pasting gave the same result when pasted into an rtf program (I used Wordpad on Windows for this). So how do I copy the hierarchical structure?

My use case requires the binder text to be used as a table of contents; plain text only. Once I got a (non-hierarchical) structure into a text file, I tried to run a sed command on it. The reason for this is that the table of contents structure has to have a specific format for mdbook:

sed -E 's/(^.*$)/[&](.\/&.md)/' input.txt > output.txt

The first time I ran this program it failed. I couldn’t figure out why; then I found that about 125 lines or so had no paragraph endings. Why would some binder entries end with paragraph marks (pilcrows) while others do not? I don’t know. I fixed this by adding paragraph marks (used Textsoap and Textwrangler) and removed all blank lines, after which the sed program ran. However, I found by running the cat command that there were many non-printing characters in the file. A lot of cruft! And not just paragraph symbols, hashtags and the like–running the cat command yielded all this.

This was strange because I had copied everything into an empty text editor (Atom) on the Mac and none of this extra “content” was visible.

I’m adding this in case someone needs to build a plain text file from the binder and needs to troubleshoot. Your text file may contain lots of data you don’t want. When you “copy special” (still don’t get why a simple copy doesn’t work) you may find that there is a lot of hidden information that comes over.

The goal, btw, was to publish the information contained in the Scrivener project file to the web.
My workflow is too complicated: source files to Scrivener, editing there, then export to Markdown (or text) then build a structure in mdbook (SUMMARY.md - mdBook Documentation).

I wonder if there’s a way to directly export to html from Scrivener, using the binder as a table of contents. I have not tried to experiment by compiling directly to html; maybe I’ll try this and see what happens. A long, unpaged file wouldn’t help; I’d need a directory listing and a ToC, the project is 245,000 words or so. A Scrivener to e-pub works well, the problem is that e-pub readers choke on files this big.

(Update 1700 AST) Just compiled to html (web page). The advantage is that all the images transferred flawlessly (they were lost in the “Save as” .txt previously). The disadvantage is that there’s a unpaginated scroll with no means of navigation. The binder doesn’t (as far as I can tell) set up any navigation when compiling to html.

I had to come back to this issue because I needed to have a hardcopy with the hierarchy. First, after manually selecting the binder, the standard “copy” option was greyed out. Copy special was present; copying both “as ToC” and “as Structured Link List” on pasting gave the same result when pasted into an rtf program (I used Wordpad on Windows for this). So how do I copy the hierarchical structure?

Both of the “special” commands only have significance when pasting into Scrivener, given the results of the commands being largely useless outside of it (a bunch of internal Scrivener links and page number placeholders in the former case). Sorry, when you said “an editor” I thought you meant in the project window.

One thing I noticed is that you mentioned you’re using Windows (this is a Mac thread). So I’ve been using the wrong platform to test with. There is indeed a bug with the regular Copy command on the binder. That isn’t working yet—but it’s rather beside the point since that only ever produces a flat list anyway.

But did you try the compile method I mentioned? That should be producing an indented text list.

I’m adding this in case someone needs to build a plain text file from the binder and needs to troubleshoot. Your text file may contain lots of data you don’t want. When you “copy special” (still don’t get why a simple copy doesn’t work) you may find that there is a lot of hidden information that comes over.

That’s all quite strange. You seem to be referring to text content having odd paragraph breaks and such, but this command should only be copying titles, right? I’m a bit confused at this point I think. I thought you were just trying to produce a nested list of titles, but it sounds like you’re trying to do something else entirely.

As for weird characters in general, the Edit ▸ Text Tidying ▸ Zap Gremlins command may help. I’ve found the Mac text editor has bugs that cause the insertion of control codes into the document, and this can mess up processing tools that aren’t expecting them.

If you are ultimately trying to get a bunch of .md (or .html) files out of the compiler though, then this post-processing technique would be a good starting point. Since that will be splitting up a long compiled document into multiple files, based on a Layout that inserts a file break separator, it would be easy to keep track of document names and build a ToC file in the background, finally writing it out to a separate file once all of the individual .md files are written out.

Of note: that script was built for someone looking for .tex files, so it would require a little tweaking for another purpose. It is also only set up for Mac use at the moment. The script itself is embedded in the Processing pane settings.

By "editor I meant a text editor. Understood about pasting into Scrivener (i.e., copying the binder and then pasting) but why is plain “copy” greyed out?

Depends on where I am: I have (at least) three licenses; one for Windows, one for Mac, one for iOS that I don’t use at all.

Right. I wasn’t trying to copy file content at all. Just the titles in the binder.

Zap Gremlins: forgot about that, that’s a good idea.

I wasn’t compiling because mdbook requires a table of contents file and then uses that to build a web pages based on multiple files in a single directory. If you mean, highlight “Draft” and then just compile that single list, I could try that. What I ended up doing was:

  1. Create Scrivener Project (200 chapters)
  2. “Save as” text files. This gives me 200 files. Change extension to *.md, put in a single directory.
  3. Try to copy the binder (but not the files, all I need is the structure). Copy that into a text editor. Run the ‘sed’ command on it so each line looks like this:

Introduction

  1. compile mdbook. I’ll get a web page, with a navigation link for the “Introduction” file with its contents displayed.

I’ll try the post-processing technique for the next project.

Thank you very much.

Yeah, lacking a post-processing script to split up a compiled document for you into a directory structure, that sounds like a good way to get it out for now.

Something I have on my infernal-someday todo list is to broaden that sample project a bit, so that it supports several different file types rather than just .tex files. In fact I think the very first version of that project that I made for someone was indeed for a mdBook type system (either mkDocs or Git’s documentation service). I’ve even toyed with creating a compile format for the user manual that produces mkDocs format. Thanks for the pointer to mdBook though, I like the look of that design, it is cleaner and more accessible looking than mkDocs.