Export as barebones HTML?

I’m struggling to export my text in the way I need it for importation into a code editor. Really, I just need

tags as well as tags for bold, italics, etc. That’s about it.

I can actually export to rtf or doc(x), and use regular expressions to wrap my paragraphs with

, right in Scrivener. So far so. But the problem is wrapping the italics, etc. Scrivener does have a search for font style, so it can find all my italics, but the font-style search function doesn’t allow for replacement using expressions. I use a lot of italics, so I really need that.

So then I tried exporting as HTML. That basically works, except that is exports as fully formatted with styles out the wazoo. There’s so much code I’d have to edit out, it would actually be easier to just add in all my own and tags in the rtf export.

So I’m wondering if there’s a way to export what I’m thinking of as “barebones” HTML. Just give me my markup and

tags, and that’s it. Is this possible?

Short of that, if anyone can think of a way to search for font styles and then wrap those styles in tags, I’m wide open for suggestions. Yes, I know MS Word can do all this, but I’m a Mac user and don’t own a copy of Word. I left behind all things Microsoft many years ago and don’t want to go back. Apple Pages and Open Office also do not have regular expression capability powerful enough to do what I’m looking for.

Hello, I signed up because I needed to post a new question, as my Scrivener syncs automatically to External Files despite 3 re-installs. But, Scrivener seems to limit my posting ability to replies! How did you post this question? Thanks so much?

Nisus Writer Pro https://nisus.com/pro/ has a full regex search and replace, a very powerful macro language—you can also macroize your S&R routine when you’ve got it working if you don’t want to write a macro from the ground up—and several very knowledgable and helpful macro experts on the forums.

It’s native format is RTF, so it works extremely well with Scrivener, but can also save as plain text, of course.

They give a 15-day demo download if you want to give it a try.

Just a user of both.

You can use styles for this. Instead of using bold/italic RTF, you use Emphasis and Strong character styles (and any other styles you want, you could do things like blockquotes code blocks or figure blocks etc. etc). The compile format would output plain text, with each character style inserting the correct HTML tags.

Another alternative is to use Markdown for this, as the output HTML is much cleaner, but I think it would involve more work for you. In fact, with character/paragraph styles you can output barebones HTML and markdown from the same editor source just by using different compile formats, this is the sublime flexibility of Scrivener 3…


To post a new question, select the appropriate sub- forum - for you probably Technical Support, Mac - literatureandlatte.com/foru … um.php?f=2 . There is a large friendly red button for “New Topic”



If you’re using Scrivener 3 then I’d say you already have a good option for exporting clean HTML: Markdown. And I don’t by that mean you have to adopt writing in Markdown style as you work (though you certainly can if you want—there are whole systems in the compiler built around that workflow), I mean you can throw a switch in any of the MultiMarkdown or Pandoc based file types at the bottom of the Compile For menu and take full advantage of these technical formats and HTML5 compliant outputs without using a single shred of Markdown in your writing. You’ll find the conversion to be quite comprehensive, and the ability to plug gaps with Styles making it perhaps 99.9% complete.

You can give it a 5-minute test run without any modification to your current settings or work:

  1. Select Compile For: MultiMarkdown → Web Page (.html).
  2. Click on the General Options tab on the left hand (gear button) and enable, Convert rich text to MultiMarkdown.
  3. For your Compile Format, I’d recommend sticking with the stock “Basic MultiMarkdown”, at least as a starting point. You don’t need much glitter and fireworks with this workflow, seeing as how it is purely semantic. There’s no picking out fonts or choosing from myriad design options: you’re just getting

    elements anyway, right?

  4. Assign your section types to layouts based on the simple premise of whether or not they need hierarchical headings (h1 – 6).
  5. Click Compile and give that an audit against the original.

I’d say the main thing to be looking for are WYSIWYG conventions you’ve done in the editor that aren’t coming through. Since you mention wanting pretty basic HTML though, I’m guessing this may just be all you need to do. But, if you do realise there were some things here and there you were relying upon the HTML engine to handle (maybe you put headings in the text instead of using the compiler to generate heading structure for instance), then you may need to do a little style-based work.

Headings, incidentally, are easy. I’m assuming if work with headings in the text, you’ve already set them up to use Format ▸ Paragraph ▸ HTML Level settings (and with our built-in “Heading 1” and “Heading 2” styles they will be that way by default)—if so then you’re done. :slight_smile: The MMD conversion engine will turn those into “##” style Markdown headings, which of course then gets converted straight back to “h2” or whatnot. If not, it’s a simple fix to get the style updated with that setting centrally.

If you’ve used our stock styles for the basics, like block quotes, or captions under images, then you’ll find most things work as you’d expect, and perhaps better than you’ve experienced from Scrivener before for that matter.

But if for example you have a special style you use that colours text red (or whatever), you won’t see that coming through by default. For Scrivener to convert the text to Markdown, there has to be a thing in Markdown that does “red text”. If there isn’t one uses raw HTML, and in Scrivener one can put raw HTML around styled text at will:

  1. Right-click on the “Basic MultiMarkdown” Format and “Duplicate & Edit”.
  2. Click on the Styles pane, and then the + symbol, selecting the project style you wish to address from the list.
  3. Set Treat as raw markup so you can type in your own HTML, and then do so using the available prefix/suffix fields. For example:
<span class="something">



That should cover the basics, the intermediates and even some advanced stuff as well. And since at most all we are doing in the editor is adding or adjusting styles a bit—we aren’t touching your project’s ability to continue using the WYSIWYG style outputs one bit. Everything that makes this work happens in the compile Format itself, and the settings that are bound to that format.

One last thing: if you prefer a “snippet” of HTML rather than a full document with a head and body, then go into the Metadata compile option pane and remove the “Title” and “Author” metadata keys from the lower section.

Thanks! I’ll give it a look!

Wow, holy schnikes! Yes, I was somewhat familiar with Markdown, but didn’t notice the option to export as Markdown > HTML. The result I get is pretty fantastic. Basically, all I want are

wraps and wraps (Scrivener outputs and , but whatever: I can’t change it if I want, I suppose). There are a few oddities I’m seeing, but nothing I can’t fix up in a jiffy with find and replace in a code editor.

Yes, I want to use my own styles and build my own headings, etc, so I just want to get the text out. This is about a perfect solution. THANK YOU!