mljrg
mljrg

Reputation: 4620

How to indent a paragraph and still have normal paragraph style?

I would like to ident every line in a paragraph in a way that results in this style

lipsum lipsum lipsum lipsum lipsum

instead of this style

lipsum lipsum lipsum lipsum lipsum

Is there a simple and practical way to get this effect on a paragraph by starting the first line with some special command ? For example

COMMAND lipsum lipsum lipsum lipsum lipsum
lipsum lipsum lipsum lipsum lipsum
lipsum lipsum lipsum lipsum lipsum

would result in

<spaces inserted here> lipsum lipsum lipsum lipsum lipsum
<spaces inserted here> lipsum lipsum lipsum lipsum lipsum
<spaces inserted here> lipsum lipsum lipsum lipsum lipsum

Thanks

Upvotes: 2

Views: 4769

Answers (1)

eskwayrd
eskwayrd

Reputation: 4521

The verse and literal roles would normally be the solution, but both result in monospace text, which is not what you want.

The solution is to use custom styling, but how you implement that styling depends on the output format.

For HTML output, it is fairly straightforward to accomplish: you would add custom styling via the docinfo facility: https://asciidoctor.org/docs/user-manual/#docinfo-file And a custom role that uses the style.

For example, if you create a file called docinfo.html in the same folder as your Asciidoc markup file, containing the following content:

<style>
.indent {
    padding-left: 4rem;
}
</style>

You then have the CSS style to indent specific paragraphs.

Then, in your Asciidoc markup file, add the :docinfo: shared attribute immediately after the document title (no blank lines between them). That tells asciidoctor to include the docinfo.html content within the <head> portion of the generated HTML.

Finally, whenever you have a paragraph that needs to be indented, include the [.indent] role.

Here's an example document:

= Document
:docinfo: shared

A normal paragraph.

[.indent]
An indented paragraph.

Another normal paragraph.

The solution would be similar for EPUB output (I think). For PDF, you would have to customize the theme being used. See this document for theme customization details: http://gist.asciidoctor.org/?github-asciidoctor%2Fasciidoctor-pdf%2F%2Fdocs%2Ftheming-guide.adoc

Upvotes: 3

Related Questions