Tab entire paragraph

I’m attempting to put a code block in using MMD. It seems like the whole paragraph should be tabbed, but is there an easy way to select a whole paragraph and tab the whole thing over?

I’m trying to avoid pasting my code block (could be 10-20 lines) and then going to each line and hitting the “tab” key.

Use Format > Formatting > Preserve Formatting on your code block. This won’t indent it in the editor, but when compiled with as MMD, the tabs will be added automatically to the beginning of each line in the Preserved Formatting block.

This is perfect! Thanks!

One other question on that note…I’ve been working on something for awhile that has code blocks in it. I previously used fenced code blocks wrapped with (3 backticks). When I export that, the "" are preserved even though that’s a standard method for defining a code block.

Is there something I can do get it to be recognized as a code block?

Your solution works well going forward, but I’d prefer not to go back and do that to all the existing text.

If you are already using the triple back-tick to mark out code sections, you should not need to be indenting (or by proxy, using Preserve Formatting) in the first place. That is all you need to mark a section as a code block, and if you indent on top of that then yes, you’ll just get three back-ticks included in the code block because you will have something like this in the output:

[code]A normal paragraph.

```
The section that you put into a Preserve Formatting block.
```

Another normal paragraph.
[/code]

If you’ve got a result that looks like that when you compile, then you’re escaping your escapes, so to speak. :slight_smile:

My existing paste, has 3 backticks and NO indent, and it doesn’t not export as a code block. any idea why?

Again, it’s really hard to say without knowing what the raw MMD itself looks like after you compile. I myself had no problems testing this out. I made a simple project with some placeholder text, and enclosed a line in ``` with a clear space before and after the fence, then chose to compile MMD->HTML. The resulting file looks clean in a browser and as HTML code. Here is what the source looks like in Scrivener:

[code]Dri srung gronk ozlint; zeuhl la, ti dri. Relnag xi nalista dri lydran wynlarce, prinquis zorl nalista, zeuhl re obrikt relnag erk wynlarce wex pank gronk? Menardis clum, morvit xu ma yem twock irpsa ma cree tolaspa. Erk teng flim obrikt; menardis nix frimba tharn nalista kurnap rhull.

An extended code block.

Re teng thung; kurnap fli rintax ti nalista gra athran epp. Er lamax berot cree dri. La, morvit urfa quolt… er prinquis, pank obrikt quolt gen ma dri tharn athran relnag xi erc wex velar. Thung ik la flim urfa su ewayf thung. Berot wynlarce—gen nix srung athran er vusp gen, sernag jince. Ma er ma jince ma rintax ma wex ux wynlarce. Xu, zeuhl lydran ux erk. Sernag epp anu er cree ik korsa groum rintax velar ozlint velar thung vo korsa berot menardis er arul.
[/code]

That is what it also looks like if I compile as MultiMarkdown, naturally, since I’m not doing anything special with it in Scrivener. It’s just passing the text I type through to the output.

And here is the HTML output:

[code]

Dri srung gronk ozlint; zeuhl la, ti dri. Relnag xi nalista dri lydran wynlarce, prinquis zorl nalista, zeuhl re obrikt relnag erk wynlarce wex pank gronk? Menardis clum, morvit xu ma yem twock irpsa ma cree tolaspa. Erk teng flim obrikt; menardis nix frimba tharn nalista kurnap rhull.

An extended code block.

Re teng thung; kurnap fli rintax ti nalista gra athran epp. Er lamax berot cree dri. La, morvit urfa quolt… er prinquis, pank obrikt quolt gen ma dri tharn athran relnag xi erc wex velar. Thung ik la flim urfa su ewayf thung. Berot wynlarce—gen nix srung athran er vusp gen, sernag jince. Ma er ma jince ma rintax ma wex ux wynlarce. Xu, zeuhl lydran ux erk. Sernag epp anu er cree ik korsa groum rintax velar ozlint velar thung vo korsa berot menardis er arul.

[/code]

I should note that I am on MultiMarkdown 4.5, rather than the built-in version of MMD that comes with the Scrivener installation (3.7).

I did some experiments and if I made a new document in Scrivener and use the 3 backticks, it works ok. However, with the content that I pasted in from my previous documents don’t work with that format.

[code]Traditionally, if it’s something small, you might bite the bullet and just
include it in the view template:

<%# app/views/page/contact.html.erb %>

<h1>Contact</h1>
<p>This is the contact page</p>

<%= javascript_tag do %>
  alert("My example alert box.");
<% end %>
```[/code]

produces:

[code]<p>Traditionally, if it's something small, you might bite the bullet and just
include it in the view template:</p>

<p>```
&lt;%# app/views/page/contact.html.erb %></p>

<h1>Contact</h1>


<p>This is the contact page</p>


<p>&lt;%= javascript_tag do %>
  alert("My example alert box.");
&lt;% end %>
```</p>[/code]

Any idea why this pasted content from my old markdown files wouldn't work normally?

If I copy and paste the first into Scrivener and then compile to HTML, I get:

[code]

Traditionally, if it’s something small, you might bite the bullet and just
include it in the view template:

<%# app/views/page/contact.html.erb %>

<h1>Contact</h1>
<p>This is the contact page</p>

<%= javascript_tag do %>
  alert("My example alert box.");
<% end %>
[/code]

Do you have any custom compile settings? If not, maybe try resetting it to “Original” and see if it works. I’m not sure though—like I say, Scrivener doesn’t really do anything at this level. How text gets converted to HTML is entirely up to MultiMarkdown.

It appears to be the empty lines that are inside the code block. If they’re removed, it compiles for me as

<p><code> &lt;%# app/views/page/contact.html.erb %&gt; &lt;h1&gt;Contact&lt;/h1&gt; &lt;p&gt;This is the contact page&lt;/p&gt; &lt;%= javascript_tag do %&gt; alert(&quot;My example alert box.&quot;); &lt;% end %&gt; </code></p>

Otherwise, I get

[code]

```
<%# app/views/page/contact.html.erb %>

Contact

This is the contact page

<%= javascript_tag do %> alert(“My example alert box.”); <% end %> ```

[/code]

This is with the Original preset but using the bundled MMD version, so could the difference here be a difference between 3.7 and 4.5? (Caveat: I know basically nothing about working in MMD, so this is just me experimenting with it while waiting for my Windows machine to do stuff. It is conceivable I did something wrong. :wink:)

For some reason the drop down was on “Custom” instead of “Original”. I changed it back to “Original” and it seems to work, however, there was no change settings. I honestly have no idea how it got on Custom in the first place. I was probably tinkering around to see if I could get it to work.

I do have MMD 4.5 installed, so maybe that’s playing in to this too. I was able to get it to compile properly even with spaces in the code block.

Thanks again for your help. Sorry for the confusion.

All “Custom” means is that something was changed somewhere. It could have even been changed back to the original value, but once it has been changed Scrivener cannot know what it was before, so it just calls it “Custom”. There must have been something somewhere though that was throwing it off. I can only think of a few things—maybe the whitespace conversion feature in the Transformations pane could cause some grief if there is visual formatting in the editor being turned into literal spaces.

A year later, but I found myself struggling to get the code blocks correct.

With the standard 2.6 version of Scrivener on the Mac I found indeed, like MimeticMouton pointed out, an empty line within the block disturbs the fenced code block. However after installing MMD 4.5 the same text is converted correctly. So the version of MMD does play role.