How to add Bold or Italic (INLINE) using Jade? *Like markdown
Asked Answered
A

3

15

There is some way to make strong some words in the same code line using Jade to generate the HTML?

I try to use markdown code, like this. But isn't working:

p Here are my **strong words** in my sentence!

An unique solution that I found (here) was:

p Here are my <strong>strong words</strong> in my sentence!

There any other way?

Thank you!

Azoic answered 16/3, 2016 at 15:9 Comment(0)
M
21

I think you can simply do:

p Here is my #[strong strong words] in my sentence!
Mortimer answered 14/4, 2018 at 14:48 Comment(1)
That's what I was looking for! Thank you! :DAzoic
E
21

For Pug or Jade, you need to wrap the element in a paragraph, and use the | for line continuation.

p
  strong This Starts out strong 
  |  but finishes out not 
  i  quite 
  |  as bold.

Which will look like:

This starts out strong but finishes out not quite as bold.

EDIT: As noted in the comments, you need an additional whitespace before each component, as pug doesn't add spaces. The above will render out as:

<p><strong>This Starts out strong </strong> but finishes out not <i> quite </i> as bold.</p>
Euphrasy answered 27/1, 2017 at 9:55 Comment(2)
Except, that's not how it renders. Pug doesn't add white space in-between each of your lines. (e.g. This Starts out strongbut finishes out notquiteas bold.)Latarsha
Correct. You need to remember to add the &nbsp; at the end of the first line (&nbsp; == "non-breaking space")Onitaonlooker
M
21

I think you can simply do:

p Here is my #[strong strong words] in my sentence!
Mortimer answered 14/4, 2018 at 14:48 Comment(1)
That's what I was looking for! Thank you! :DAzoic
B
3

You can use a span tag with style attribute (or CSS class).

p Here is my&nbsp; span(style='font-weight:bold') strong words &nbsp;in my sentence!

Or you can do the same formatting (add line break and indent) with strong tags.

p Here is my&nbsp; strong strong words &nbsp;in my sentence!

Brandi answered 14/6, 2016 at 21:0 Comment(3)
Whilst this solution works it produces this warning Warning: missing space before text for line X of jade file. Any way this can be avoided?Shelve
'p Here is my strong strong words | in my sentence!'Azoic
p Here is my(space) strong strong words |(space)(space)in my sentence! Try this code, @ShelveAzoic

© 2022 - 2024 — McMap. All rights reserved.