Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make markbind styles cumulative on top of bootstrap styles #339

Closed
damithc opened this issue Jul 15, 2018 · 5 comments · Fixed by #1294
Closed

Make markbind styles cumulative on top of bootstrap styles #339

damithc opened this issue Jul 15, 2018 · 5 comments · Fixed by #1294

Comments

@damithc
Copy link
Contributor

damithc commented Jul 15, 2018

v1.9.0

Example: Bootstrap allows <p class="lead"> some text </p> to be used to show leading text of an article in a different formatting.
image

This normally works in markbind, but as soon as we apply some markbind formatting on the text, it overrides the bootstrap formatting. e.g., <p class="lead"> **some** text </p> will show the text in normal formatting + bolding

Suggestion: in general, it's nice if our own styles such as bold/underline/tooltip etc. can be applied on top of styles applied by bootstrap.

@Chng-Zhi-Xuan
Copy link
Contributor

Chng-Zhi-Xuan commented Jul 23, 2018

It is actually possible to do so.

The issue comes in because rendering markdown content produces a <p> tag. Nested <p> tags are strictly not allowed in HTML specifications, and will terminate upon detecting a child element with a <p> tag.

The P element represents a paragraph. It cannot contain block-level elements (including P itself).

Before

<p class="lead">
  Lorem **Ipsum**
</p>

After

<p class="lead"></p>
<p>Lorem <strong>Ipsum</strong></p>

Recommend you explicitly use <md> to specify markdown content within a paragraph tag, which doesn't generate a <p> tag.

@damithc
Copy link
Contributor Author

damithc commented Jul 23, 2018

That worked. Thanks for the workaround. 👍
Is it necessary for markdown to add a <p> tag? Should we try to get rid of it?

@Chng-Zhi-Xuan
Copy link
Contributor

It is there for cases where you have markdown content without any parent element, since it is not good to have stray text floating around in a HTML page. We should keep it as it helps us to ensure our pages are properly formatted.

Some info: Most markdown content is parsed through markdown-it's render method and it generates a <p> tag by design. While <md> uses markdown-it's renderInline that doesn't generate a <p> tag.

@damithc
Copy link
Contributor Author

damithc commented Dec 24, 2018

It is there for cases where you have markdown content without any parent element, since it is not good to have stray text floating around in a HTML page. We should keep it as it helps us to ensure our pages are properly formatted.

I guess it is not easy to restrain this 'add <p> everywhere' behavior to cases where it is actually needed? I suspect adding <p> tags can cause unexpected behavior in other places too.

@damithc
Copy link
Contributor Author

damithc commented May 20, 2019

This workaround can be documented as a 'how to'

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

Successfully merging a pull request may close this issue.

3 participants