I need to share a piece of a Scrivener document on a phpBB forum. I’m compiling from Scrivener into plain text, and am wondering if it is possible to surround all instances of bold and italicized words with the BBCode for bold and italics. So, for example, a bolded phrase would end up as This is bold and italics would end up as This is italics.
Thanks for any help.
I just stumbled upon the discovery that, at least for italics, this is a built-in option. In the Compile settings for TXT files, under Markup put your BBCode in the boxes for “Enclosing markers for unstyled italics” as shown in the attached image.
I’m not really sure why the Markup pane includes a setting for unstyled italics, but for that one thing, yeah you can use that.
Otherwise I would say that in general a style-based approach is best for cases where the text might need to be flexibly output like this . You don’t need a special hook built into the compile pane if you have the Styles pane already, which comes with a prefix/suffix capability. So mark you text “Bold” with a style, not with fonts, and then have the style compile [b] and [\b] around such selected text. I’d the same for italics myself, after all it is really emphasis I wish to convey. Perhaps I will use the customary italic font face to express that, but maybe not?
Do you use Markdown by the way? You could generate even more sophisticated BBCode with a Pandoc output filter, like I do. I don’t tend to compile, I have a macro that copies the text out of anywhere, converts the text to BBCode and sticks it into the clipboard so I can paste it anywhere. But it would be possible to set up the compiler to generate BBCode from Markdown, too.
Thank you for the reply. I taught myself Styles last night, and created a style to apply the italics. I also just created a Keyboard Maestro macro to intercept my Cmd-I keystroke (in Scrivener only), and enter my Style shortcut keystroke. A bit quicker for me.
Regarding Markdown, I actually use it all day long at the day job. As much as I am a huge Markdown fan, there’s just something about actually seeing italics in Scrivener (especially in creative writing) that I can’t put my finger on. Maybe I’ll rethink that.
If you have a lot of existing text that you need to process that was just done with italics (or bold), then you could handle that on an ad hoc basis by taking the text into Word – you can search for italics or bold there and replace the found text with the code-embraced found text.
Well if you are interested in a full conversion script, I’ve attached what I use. The Keyboard Maestro macro will grab the current selection (or the entire buffer) and run Pandoc conversion on it, to generate BBCode and insert it into the clipboard. The way I use it is as a hot key, where I have multiple Copy+Plus type commands. I copy out of Scrivener with that, then switch over to the browser and paste.
That’s not going to work out of the box with formatting though. It every much expects the content in the editor to be Markdown. What might work however, is if one writes completely in rich text, to modify the copy macro so that it uses Edit ▸ Copy Special ▸ as Markdown. Like I say though, that won’t work if you use any Markdown at all as it will escape all of the characters that could inadvertantly trigger Markdown. I.e. your asterisks will end up visible in the output if you use them instead of the list tool, etc.
Or if you’re feeling ambitious you could take the command-line from the macro and adapt it into Scrivener’s Processing format pane, thus making your own Bbcode compile format. Then you’d be able to tap into the fully hybrid workflow, with styles, convenience conversions like footnotes and images, etc.
Oh it’s worth noting that I subvert the code span syntax to generate the “interface label” coloured text you see in my posts. So when I type in a menu command, like the one above, it looks like:
`Edit/Copy Special/Copy as Markdown...`
The script converts the slashes to filled triangles and sets the font to dark red bold text. Since BBCode has no code span to begin with, only code blocks, it seemed a fair trade.
copy_as_bbcode.zip (5.41 KB)
Thank you, AmberV. I may dig into that and play with it. I am using Pandoc on my system for one other use case, although its inner workings are a mystery to me.
GR, thanks for the suggestion. Fortunately, it was only a few changes, so it took me about 5 minutes doing a search and replace.