Export with partial HTML tags


I consider myself a bit of a n00b with Scrivener, even though I have used it for over a year now :slight_smile: So perhaps this feature exists already, but I cannot find it.

What I need to do is export a document mostly as plain text, with empty lines for paragraphs, but I want to have HTML tags to represent the parts of my text which are italic and bold.

This is how many older document entry systems work on the internet, where they try to “hide” the HTML nature but still allow you to use certain HTML tags if you wish.

I spent a little time in the export section but I do find it quite confusing. Is there any preset for this or is there a way to make Scrivener do it out of the box? Otherwise, could I request this as a feature?

For copying into a WordPress comment box, for example! I actually wrote an AutoHotKey script to do this, starting from the HTML markup we can obtain from the Copy Special command. Kinda like ungrinding sausage. Sorry, too complicated and fragile to share.

Scriv’s Copy as BBCode is similar in its objective, but it’s buggy and we’ve heard it’ll be removed from Version 3.

Rgds - Jerome

Scrivener 3 will allow you to use styles (e.g. strong and emphasis, but any style can be set up) and these can be transformed into whichever HTML tags you would want, which should flexibly solve your problem. 8)

Thanks for the replies.

Jerome, I know a little Python, so I may investigate that Copy Special thing. Thanks for the hint.

Look forward to version 3 :slight_smile:

Styles in Scriv 3 will enable the user to designate a stretch of text a Blockquote and have it processed as a Blockquote all the way through to the Epub, irrespective of the formatting instructions used to achieve that effect within the editor. And we’ll be able to make our own styles based on any RTF formatting we’d like to reuse by name.

But there’s no evidence we’ll be able to use those styles to structure our own HTML output. We might make our own (redundant) style called Bold. But Scriv would still determine whether that style is implemented as or as . It’s not natively an HTML editor built to give us that level of control.

And in fact a global style requires doing away with inline formatting instructions, so the HTML generated thereby would probably be more like . Sure, “Bold” lives on in the name in our example, but the implementation of the format would reside in a stylesheet suited to the destination medium. This styling by external reference is a generation removed from the “street” HTML used in WordPress comments.

Keith did blog that Scriv3 uses MultiMarkdown as the bridge format, upon Compile, between the RTF maintained by the editor, and the HTML5 required by EPub3. If we’re fortunate enough to have that MultiMarkdown rendition also available on Copy Special and on Export Files, it will become much easier to generate our own light variety of HTML from a Scrivener doc.

Rgds - Jerome

Any style can be replaced with prefix and suffix. This means for a large class of HTML tags, we can simply add the opening and closing markup for that. So as a concrete example, I create an inline style called “Strong Emphasis”, and in the compile settings I add PREFIX= and SUFFIX= then compile will perform this arbitrary style⇨markup conversion. Yo can even rebind ⌘B and ⌘I so they use your custom styles instead of the RTF bold/italic. We will even be able to add complex HTML markup for comment annotations, as we now can identify the comment and the selection seperately. So for example you can convert a Scrivener comment into a SELECTED TEXT. I use this system to allow me to use Scrivener paragraph and inline styles for all of my writing, yet they are all accurately transformed in to Pandoc flavoured markdown.

Personally, I would use MMD/Pandoc to generate HTML, but we do now have the ability to create a powerful custom HTML generator using style transformation! 8)

Well I created a solution, thanks to JJSlote’s hint.

I compile the story to HTML instead of TXT, and then I run the enclosed Python script, giving the HTML file as the command-line parameter. It writes the corresponding TXT file. Only works for so far but extending it for bold, underline etc. should be easy enough.

Scriv’s HTML output is extremely verbose. The script works by parsing the style attribute and searching for font-style:italic. That’s basically it, apart from a small HTML parser that tracks

and and handles

That’s me happy for now so thanks for everybody’s help!

Convert.txt (3.04 KB)

Well, there’s the evidence! Great digging; appreciate the V3 preview, nontroppo.

Rgds - Jerome