Skip to content

Readable multi-line quoted string literals #13860

Description

@dbuenzli

If you want to include precise content with multi-line quoted string literals it forces you to botch its layout: you need to flush-left the content in your sources and this can't align with the start of the literal starting mark.

To give an example assume you have the following content and wish to preserve the exact white space in a quoted string literal:

1. This is the first point
 2. This is the second point

You need to write this as

let my_points = {|1. This is the first point
 2. This is the second point|}

or

let my_points = 
{|1. This is the first point
 2. This is the second point|}

which is not only ugly but also does not convey visually at all the actual textual content of the string. From a source code reading perspective, the design of quoted strings literals is subpar (to not say broken).

With @panglesd we recently went over the definition of code blocks in odoc. This is the outcome (full long design discussion). I think that this is the way multi-line quoted literals should have been defined.

Of course it's a bit late by now. I wonder though if perhaps we could still use a quoted-string-id prefix that triggers a parse according to these definitions. e.g. _ or __,

This would allow for example to write the above content, with natural indentation, as:

let my_points = {_|
                1. This is the first point
                 2. This is the second point
                |_}

or

let my_points = 
  {_|
  1. This is the first point
   2. This is the second point
  |_}

while retaining the exact whitespace content and visual representation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions