Skip to content

Docbook literallayout is treated as monospace by default #10825

@nicorikken

Description

@nicorikken

Problem

The default behavior for DocBook literallayout should be normal text with hard line breaks. The monospace output that Pandoc now produces is only intended when the class is set to monospace.

The class attribute gives users control over the font used in literallayouts. If the class attribute is specified and its value is monospaced, then the literallayout will be presented in a monospaced font. The default value for class is normal, meaning that no font change will occur.

Example

Minimal example, tested on Debian 12 Bookworm with installed Debian package of Pandoc 3.6.4.

DocBook input

<?xml version="1.0" encoding="utf-8"?>
<book xmlns="http://docbook.org/ns/docbook" version="5.0">
  <info><title>Literallayout test</title></info>
  <chapter>
    <info><title>Literallayout without class</title></info>
    <literallayout>First line.
Second line.
  Third line, indended two paces.</literallayout>
  </chapter>
  <chapter>
    <info><title>Literallayout with normal class</title></info>
    <literallayout class="normal">First line.
Second line.
  Third line, indended two paces.</literallayout>
  </chapter>
  <chapter>
    <info><title>Literallayout with monospaced</title></info>
    <literallayout class="monspaced">First line.
Second line.
  Third line, indended two paces.</literallayout>
  </chapter>
</book>

Markdown output

pandoc -f docbook -o literallayout.md literallayout.dbk

# Literallayout without class

    First line.
    Second line.
      Third line, indended two paces.

# Literallayout with normal class

    First line.
    Second line.
      Third line, indended two paces.

# Literallayout with monospaced

    First line.
    Second line.
      Third line, indended two paces.

Expected Markdown output

# Literallayout without class

First line.\
Second line.\
&nbsp;&nbsp;Third line, indended two paces.

# Literallayout with normal class

First line.\
Second line.\
&nbsp;&nbsp;Third line, indended two paces.

# Literallayout with monospaced

    First line.
    Second line.
      Third line, indended two paces.

HTML output

pandoc -f docbook -o literallayout.html literallayout.dbk

<h1>Literallayout without class</h1>
<pre><code>First line.
Second line.
  Third line, indended two paces.</code></pre>
<h1>Literallayout with normal class</h1>
<pre><code>First line.
Second line.
  Third line, indended two paces.</code></pre>
<h1>Literallayout with monospaced</h1>
<pre><code>First line.
Second line.
  Third line, indended two paces.</code></pre>

Expected HTML output

<h1>Literallayout without class</h1>
<p>First line.<br />
Second line.<br />
  Third line, indended two paces.</p>
<h1>Literallayout with normal
class</h1>
<p>First line.<br />
Second line.<br />
  Third line, indended two paces.</p>
<h1>Literallayout with
monospaced</h1>
<pre><code>First line.
Second line.
  Third line, indended two paces.</code></pre>

For Markdown the non-break spaces and backslash line breaks are used to maintain layout without using monospace. In HTML the explicit line breaks are sufficient. Each output of course would have different ways of maintaining layout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions