BLOCK, Paragraph and Character Styles

Posts: 9
Joined: Thu Jan 04, 2018 3:59 am
Platform: Mac + iOS

Sat Jan 13, 2018 6:10 am Post

(English is not my primary language)

I have been reading the tutorial and playing around the compile settings. It seems that the only formats one can apply are Paragraph and Character styles.

I am working primary with ePubs and Web Pages, so having options for custom HTML classes and Styles are great. Yet, I have not find (and at this point I think is not posible) a way to use/apply Styles that will generate a DIV surrounding paragraphs. For example: let's suppose I want three paragraphs left-aligned but inside a box that is floating to the right. For this I can use a HTML/CSS like this:

Code: Select all

<div class="box">
   <p>Short Paragraph.</p>
   <p>Another short one.</p>
   <p>Longest paragraph of all.</p>

Code: Select all

.box {
   margin-left: auto;
   text-align: left;
   background: blue;

The reason I need the DIV is so everything align to the left (and the box to the right) while using the longest paragraphs as the width setter. That way the left side of the block will be justified.

Notice that the margin-left only applies to the <div> (for the <p>s does not inherit that property) and the text-align to the paragraphs.

There are many other ways to accomplish this, but the point is that more often that not one need to use a DIV surrounding paragraph to manage more complex design.

If this option does indeed exist, please point me in the right direction. If not, please, consider adding a third type of style that create divs. That way I can select this 3 paragraph, apply a "Block" Style and then control it in the custom CSS options.

This will also make the creation of accessibility and other features in ePubs/HTML way better and easier.

Character Styles are the equivalent of <span> (the universal display:inline). And we could use the "BLOCK" Style, the equivalent of <div> (the universal display:block).

Thank you.

User avatar
Posts: 909
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Sat Jan 13, 2018 4:28 pm Post

If you are using MMD compile, you can easily assign <div/> to a paragraph style (and <span/> to a character style), using the Style prefix/suffix in the compiler.

If you use Pandoc you can also use the new Fenced Divs as the prefix / suffix, which allows you to create styles for HTML based outputs and styles for word processors: ... d-and-html

For the direct EPub3, the <div> syntax in prefix/suffix does not completely work (EPub3 compile also uses MMD but Keith may be injecting the prefix/suffix at the wrong time, or escaping HTML to deliberately stop it being used?). But try enabling treat as raw markup, the <div>s at least work:
Screen Shot 2018-01-14 at 01.05.23.png
Screen Shot 2018-01-14 at 01.05.23.png (23.76 KiB) Viewed 295 times

User avatar
Site Admin
Posts: 19411
Joined: Tue Jun 13, 2006 11:23 pm
Platform: Mac
Location: Truro, Cornwall

Wed Jan 17, 2018 1:06 pm Post

<div> blocks can also be applied to Section Layouts using the Compile settings even without using MMD - you just need to assign a CSS class name to the Section Layout in the Compile format. This does mean having your <div> block in its own document in the binder, of course.

All the best,
"You can't waltz in here, use my toaster, and start spouting universal truths without qualification."