1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:28:12 +00:00

LibGemini: Improve rendering of <pre> blocks

For

    ```foo
    asdf
    jkl;
    ```bar

we would previously generate

    <pre>foo
    f
    ;
    </pre>
    ```bar

Now we generate

    <pre>
    asdf
    jkl;
    </pre>

* no longer cut off the first 3 characters on most lines.
* don't include the closing ``` line in the output. in addition to
  omitting the '```', this also honors "Any text following the leading
  "```" of a preformat toggle line which toggles preformatted mode off
  MUST be ignored by clients." from the spec
* ignore the alt text after the toggle-on text. the spec leaves it to
  the client what to do with that alt text, but it tends to be metadata,
  and omitting it is simplest for the implementation, so do that.

Improves ascii art on many gemini pages, e.g. gemini://carcosa.net/
This commit is contained in:
Nico Weber 2020-10-06 11:31:08 -04:00 committed by Andreas Kling
parent 48f13b7c3f
commit 08585bc7e9
2 changed files with 2 additions and 1 deletions

View file

@ -74,6 +74,7 @@ void Document::read_lines(const StringView& source)
} else {
m_lines.append(make<Control>(Control::PreformattedEnd));
}
continue;
}
if (m_inside_preformatted_block) {