[LH3440] Markdown Links and Links to Images Not Working with 2.90.15

The following works fine in 1.98 - the links work (external and footnote) and the image appears when compiled as Markdown -> Web HTML. But in the 3 Beta, when compiled the references simply appear as inline text in the HTML.

[code]This is a formatted ![image][] and a [link][] with attributes.

[image]: https://d3ki9tyy5l5ruj.cloudfront.net/obj/3ac85a538c3fc5bb08d0206ede04ae8aa13c20b2/inapp__logo_color_ondark_horizontal.svg “Image title” width=400px

[link]: http://www.microsoft.com “Some Link” class=external style=“border: solid black 1px;”

Here is some text containing a footnote.[^somesamplefootnote]

[^somesamplefootnote]: Here is the text of the footnote itself.

I always try compiling to MultiMarkdown plain, if one of the automated choices isn’t working as expected. The plain file shows you almost precisely what Scrivener generates and hands off to the MMD conversion engine. If you do that, you’ll see the problem is pretty obvious:

[code]This is a formatted ![image][] and a [link][] with attributes.

[image]: https://d3ki9tyy5l5ruj.cloudfront.net/obj/3ac85a538c3fc5bb08d0206ede04ae8aa13c20b2/inapp__logo_color_ondark_horizontal.svg “Image title” width=400px

[link]: http://www.microsoft.com “Some Link” class=external style=“border: solid black 1px;”

Here is some text containing a footnote.[^somesamplefootnote]

[^somesamplefootnote]: Here is the text of the footnote itself.

[somelink]:http://somelink.com[/code]

I.e. it looks like the RTF→MMD conversion mechanism was left enabled, no matter one’s settings; obviously that’s broken. The easiest workaround would have been to create a compile-time style with the raw markup flag enabled, and then use Section Layouts to apply that style to all text that isn’t already styled. Unfortunately at the moment it looks like setting the raw markup checkbox causes a crash when saving the Format—so two bugs for the price of one, it seems.

Thank you for the confirmation and explanation. Though I’d really like to make sure I understand a couple of things. I compiled to MMD and see what you posted, You say that it’s obvious the RTF->MMD option is on (even through unchecked). Is it obvious because the square brackets and carots are escaped with a ?

For example, I compiled the following to MD:

[code]Some of these words are emphasized.

  • item 1
  • item 2

And

  • item 3
  • item 4[/code]

The RTF file for this created in the Files folder by Scrivener:

{\rtf1\ansi\ansicpg1252\uc1\deff0 {\fonttbl{\f0\fmodern\fcharset0\fprq2 Calibri;}} {\colortbl;\red0\green0\blue0;\red255\green255\blue255;\red128\green128\blue128;} \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\fet2\ftnbj\aenddoc \pgnrestart\pgnstarts0 \pard\plain \tx0\tx360\tx720\tx1080\tx1440\tx1800\tx2160\tx2880\tx3600\tx4320\fi360\sl262\slmult1\ltrch\loch {\f0\fs26\b0\i0 Some of these words *are emphasized*.} \par\plain \f0\fs26\b0\i0 \par\plain {\f0\fs26\b0\i0 * item 1} \par\plain {\f0\fs26\b0\i0 * item 2} \par\plain \f0\fs26\b0\i0 \par\plain {\f0\fs26\b0\i0 And } \par\plain \f0\fs26\b0\i0 \par\plain {\f0\fs26\b0\i0 + item 3} \par\plain {\f0\fs26\b0\i0 + item 4}}

The generated MD file, shows the * for emphasis are escaped, but not the * used for lists. Why is that?

[code]Some of these words *are emphasized*.

  • item 1

  • item 2

And

+ item 3

+ item 4[/code]

I attempted to use the “treat as raw markup” flag you suggested and reproduced the crash. Though had it worked, can you explain how to “use Section Layouts to apply that style to all text that isn’t already styled”? I.e. how to apply it to text that isn’t already styled.

Thank you very much for your help.

There are a few tell-tales like that. Having all of your special characters escaped is the most obvious one, but how your line spacing was spread out is another big tell. This switch is designed for people that don’t write in Markdown—they’ll be using Scrivener like Word or similar, with one paragraph break separating each, nothing but formatting to keep them from looking like one long blob of text. So the converter is designed to take that and add newlines between them, and a lot of other things like bold, italics, tables, lists and so forth, you’d see them converted too.

With that flag off (and really being off), the assumption is that you prefer to write using Markdown, and it leaves your text alone. It’ll add stuff that makes sense, like images you’ve dropped into the editor, but otherwise it leaves your line spacing alone and doesn’t escape asterisks, etc.

Until the checkbox can correctly switch this behaviour off, compiling as Markdown is difficult. Might be easier to use plain-text, if you’re in a bind—sorry about that.

It is a pretty neat trick! You wouldn’t ordinarily think of applying formatting styles to text in Markdown settings, but when you consider what all styles can do for Markdown, it’s pretty useful.

Go into the Section Layouts area, and note at the bottom a checkbox to enable formatting override. With that enabled, you can click into the sample text and apply a style to it. It’s the icon on the far left of the format bar.

What that style does, in Markdown terms, is defined in the Styles compile pane. An example: I have a Section Layout called “Definition Item”. It prints the title of the card on one line, and then sets the style of all text in the card to “Definition”. In the Styles pane, I have this “Definition” style set to prefix each paragraph with “:”. Thus the result when compiled is:

Binder Item Title : Contents of the item. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. : : Next paragraph, and so on...

That will create a Markdown definition list, useful for glossaries and such. I.e. you can create a glossary as a folder of outline items, one per glossary entry, each one using this Layout as a template to print themselves.

As to what I mean by “text that isn’t already styled”, if you style text in the editor itself, that has the highest level of precedence in the compile system. Say you have a paragraph that is styled as a block quote within this “Definition Item” layout. Scrivener won’t change the style of that paragraph from block quote to definition, it will respect your choice in the matter. It will go on adding “:” in front of the lines around that block quote, though.

Lastly, that asterisks starting off a line are not escaped might be something we need to look at. Again if we consider this mode of operation as being used by those that don’t use Markdown, even if it is unlikely that an asterisk would prefix a line like that, it’s safer to assume the user meant to type it in and print it that way, not as a bullet item—and that means escaping it. But I’ll double-check on that.

That is super helpful, thank you.

In the Section Layouts, the checkbox to enable formatting override is always unchecked and grayed out for compiling to MMD or it’s related formats (MMD->HTML, etc.). I assigned some section layouts but that didn’t change anything. If I switch to Print or PDF, then I can check that box. Should it work with MMD as well, or am I doing something wrong?

Ah, so it is still, I hadn’t checked as I stopped looking into it once I couldn’t create a style. They are still adding formatting into the MMD variants of this pane. It looks like they have it set up in the Prefix and Suffix tabs already, so it shouldn’t be much longer. I note you can already right-click and do some formatting, but no styles yet.

Well for this problem specifically, it looks like they’ll have the root problem solved in the next beta, so no need for work-arounds to suppress conversion.

Again, sorry for the extensive amount of scaffolding here. We’ve only recently started putting MMD back together again from the overhaul.