MarkBind / markbind

MarkBind is a tool for generating content-heavy websites from source files in Markdown format
https://markbind.org/
MIT License
135 stars 124 forks source link

Reduce the need to use blank lines to indicate markdown text #500

Open damithc opened 5 years ago

damithc commented 5 years ago

Current:

<box>
**abc**
</box>

→ renders as **abc**

<box>

**abc**
</box>

→ renders as abc

Can we get the content in <box> component (and other similar components) to be parsed as Markdown by default, without needing to add a blank line or a <markdown> tag? Is there any downside to considering everything as markdown?

yamgent commented 5 years ago

Is there any downside to considering everything as markdown?

The only downside I can think of is that it would no longer be Markdown compliant, because the standard explicitly states that all content inside HTML tags must be treated as normal text, unless a blank line is added.

Markdown compliance might be important, if we expect authors to copy and adapt Markdown content from other sources.

Chng-Zhi-Xuan commented 5 years ago

Agree with @yamgent. If blank lines want to be explicitly avoided, you can always use the <markdown> tag. Although markdown content cannot be indented for a consistent look.


<box>
  <markdown>
**abc**
  </markdown>
</box>
damithc commented 5 years ago

The only downside I can think of is that it would no longer be Markdown compliant, because the standard explicitly states that all content inside HTML tags must be treated as normal text, unless a blank line is added.

Oh, I didn't know about that. in that case it is fine. But didn't we encounter a case where such a blank line would mess up the rendering? #352

yamgent commented 5 years ago

But didn't we encounter a case where such a blank line would mess up the rendering? #352

Yes, that's because the blank line also allows Markdown parsers to determine where the HTML blocks end.

The example linked in issue 352 shows an example of how the <pre> didn't get nested correctly because the end of the HTML block is determined differently. The problem faced in #352 is that nested HTML tags can produce weird/unexpected results.

So the blank line sort of "plays" multiple different roles in the Markdown specs.

damithc commented 5 years ago

I see. Is there any advice we can give users on this regard? Or any other thing we can do to improve the situation?

yamgent commented 5 years ago

Is there any advice we can give users on this regard? Or any other thing we can do to improve the situation?

We can write down the blank line behaviour in our documentation, and possibly mention the nested tags scenario, so that authors are more aware of this behaviour. Though it may become quite technical, and authors might end up doing trial and error anyway, but still worth mentioning.

Our documentation already mentions the <markdown> tags in "Content Authoring", so that should be fine.

Jekyll (which uses a different markdown library kramdown), allow authors to specify that the content inside is in markdown without having to use a blank line with markdown="1":

<div markdown="1">
This content is written in _markdown_
</div>
damithc commented 5 years ago

Jekyll (which uses a different markdown library kramdown), allow authors to specify that the content inside is in markdown without having to use a blank line with markdown="1":

<div markdown="1">
This content is written in _markdown_
</div>

Can/should we do something similar?

yamgent commented 5 years ago

Doesn't seem to have any difference in functionality, compared to what we already have though:

<div><markdown>
Some **bold** text here.
</markdown></div>
damithc commented 5 years ago

Doesn't seem to have any difference in functionality, compared to what we already have though:

Slightly more readable, for example, the two <div> tags line up.

<div markdown>
Some **bold** text here.
</div>

In cases where nested tags are involved (which is where the problem happens), one more pair of tags can make a significant difference in readability?

The only downside I can think of is that it would no longer be Markdown compliant, because the standard explicitly states that all content inside HTML tags must be treated as normal text, unless a blank line is added.

Does this apply to our own tags such as <panel>?

yamgent commented 5 years ago

Slightly more readable, for example, the two <div> tags line up.

<div markdown>
Some **bold** text here.
</div>

In cases where nested tags are involved (which is where the problem happens), one more pair of tags can make a significant difference in readability?

I guess it does save spaces, and also reduce some typing at the same time. I am open with introducing such a keyword.

Does this apply to our own tags such as <panel>?

Yes, that fits with the 7th condition in the specs.

damithc commented 5 years ago

Let's put on hold for now. Not a high priority.

jovyntls commented 1 year ago

Hi Prof @damithc , is this feature (having a markdown keyword such as <div markdown></div> to reduce the need for blank lines) still something that you'd like? Should we remove the s.OnHold tag?

damithc commented 1 year ago

@jovyntls It is still not a high priority but if it can be done easily, we can go ahead. Also wondering if the keyword should be markdown or markbind (or both).

jovyntls commented 1 year ago

Also wondering if the keyword should be markdown or markbind (or both).

I think we could stick to one keyword, in case users have the misconception that there could be different behaviours for different keywords.

Pros of using markdown:

Cons of using markdown:

damithc commented 1 year ago

I'm OK with using markdown

ang-zeyu commented 1 year ago

Agree with having <div markdown></div> in general, but it is hard as <div>s can contain not just markdown (e.g. panels, etc.).

The current <markdown/md> rendering happens in a second pass, which is simple, but makes stateful features unusable (e.g. footnotes relying on an earlier definition), and places a restriction that the content inside must be fairly simple markdown only. (else we risk rendering markdown twice which is undefined)

Ideally the markdown renderer should be altered to treat <div markdown></div> more "naturally". (that needs to be researched ~heavily~ very heavily and defined..)