Zettlr: Some text in preformatted code blocks gets extra unwanted formatting

Created on 10 Oct 2018  Â·  5Comments  Â·  Source: Zettlr/Zettlr

Description

Text in the "code blocks" is sometimes over-eagerly formatted (as Markdown). Those blocks should rather be exempt from any formatting, other than making the font fixed width.

Reproducing

Type the following markdown into Zettlr:

# Problems in code blocks
```
Some Markdown is still parsed in code blocks. Especially problematic for
comments in scripting languages:
# this gets converted to a heading
int main() {
  <- two spaces here, but looks like less (should start on "t" in "int" above)
  if (false) {
    exit(1);
  }
}
// Ascii art doesn't render well as a result:
                   .-.  .-.
                  |   \/   |
                  \        /
                   `\    /`
               jgs   `\/`
// Hyperlinks are highlighted, which is comparatively a minor complaint; it
// mostly only makes some code look weird (though also breaks fixed-width property)
const char *address = "http://www.oocities.org/spunk1111/small.htm";
```

Instead of being formatted fully with fixed-width, fixed-size font, some areas of the block get formatted with variable-size and variable-width font. More details are present in the text of the block above, as well as in the attached screenshot further below. Specifically, what I noticed:

  • lines starting with # are formatted as headings;
  • on lines starting with whitespace (indented lines), the whitespace width does not match the width of non-whitespace characters in the fixed-width font;
  • URLs are formatted with variable-width font, and different font size & color.

Expected behaviour

All the text in the ```-fenced area should be formatted purely with fixed-width font, with non-variable font size.

Screenshots

zettlr-code-blocks

Platform

  • OS: Ubuntu Linux
  • OS Version: Ubuntu 16.04.5 LTS
  • Zettlr Version: 0.19.0
  • Screen Resolution [only necessary if the bug is relating to the GUI]
confirmed enhancement

All 5 comments

Hey,

thanks for the feedback! I think I already know where most of the problems are coming from. The Markdown-mode itself does not format anything inside codeblocks (it gets formatted using the respective language parser), unless you don't pass a specific language.

That single-hash-comments are formatted as headings and links are formatted is a problem of the previewing plugins I'm using. I'm not checking against certain tokens when applying the formatting. I'll see to fixing these ASAP!

As for the spaces, I've also got an idea of what to do. If you use a specific language, you'll notice the spaces are rendered correctly.

Cheers

Whoopsie, that was easier than I thought!

You're looking for something along the lines of this, right?

screenshot 2018-10-11 at 00 22 12

You're welcome!

Heh, totally looks like what I wanted! :) Can I somehow use this fixed version already? I currently have the 0.19.0 installed, via "official" method (downloading and installing the .deb)

Heya,

unfortunately I cannot provide nightly or beta releases; this would cost too much time. If you want to test and use new features immediately, you'd have to clone the repo, switch to the develop branch and build it manually, as outlined in the readme.

The command to build a .deb-package for installation is:

$ yarn release:linux

But as for a new version: I'm currently checking my pre-release testing list, and it's looking good! If nothing bad happens, I should be able to release version 0.20 tomorrow. Otherwise it should only take until next Friday until the release is out!

Ok; cool, then I'll maybe just wait — this was fairly annoying, but not critical. Didn't know you might release it soon :) Thanks a lot for the fix and for the info!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manisabri picture manisabri  Â·  4Comments

tupio picture tupio  Â·  3Comments

Noisecommander picture Noisecommander  Â·  3Comments

tedesmac picture tedesmac  Â·  5Comments

Alopex4 picture Alopex4  Â·  4Comments