Mobileread
Replacing All Tags Of One Kind With Another
#1  Rand Brittain 10-02-2020, 07:16 PM
I've gotten into the habit of using <span class="bold"> for bold text because someone told me a long time ago that <b> was deprecated. It's lately become clear to me that this was incorrect and I should probably be using <strong>.

Is there a way to replace every instance of that particular <span> tag in an ePub, including the closing tag with a <strong> tag, other than doing it all manually?
Reply 

#2  DNSB 10-02-2020, 07:44 PM
Quote Rand Brittain
I've gotten into the habit of using <span class="bold"> for bold text because someone told me a long time ago that <b> was deprecated. It's lately become clear to me that this was incorrect and I should probably be using <strong>.

Is there a way to replace every instance of that particular <span> tag in an ePub, including the closing tag with a <strong> tag, other than doing it all manually?
Something like:

Find: <span class="bold">(.*?)</span>

Replace: <strong>\1</strong>

might work for you. Backup your file and test a couple of find/replace before doing a replace all. Note that this uses the PCRE flavour used with Sigil. Others may vary and you may need to remove the ? if the default is lazy (minimal match).
Reply 

#3  JSWolf 10-02-2020, 07:51 PM
Quote Rand Brittain
I've gotten into the habit of using <span class="bold"> for bold text because someone told me a long time ago that <b> was deprecated. It's lately become clear to me that this was incorrect and I should probably be using <strong>.
That again is incorrect. <b> is not deprecated. It works perfectly well in ePub 2/3. You are better using <b> then <strong>.

Quote
Is there a way to replace every instance of that particular <span> tag in an ePub, including the closing tag with a <strong> tag, other than doing it all manually?
The best way to do this is to install Diaps Editing Toolbag plugin. It's a Calibre editor plugin and will do what you want without the need to create your own regex. It works very well and I use it a lot.
Reply 

#4  hobnail 10-02-2020, 08:51 PM
If you're using Sigil you can use its TagMechanic plugin, which is essentially the same as the Editing Toolbag that JSWolf pointed to.

I'd forgotten about the strong tag; google brought up this article: https://www.seobility.net/en/wiki/Strong_and_Bold_Tags

So you could use strong for things you want to semantically emphasize and style it as bold in your css. In fiction my experience is that when people emphasize something said it's with italics.

So now I'm confused about the difference between the strong and em tags.
Reply 

#5  JSWolf 10-02-2020, 09:04 PM
Quote hobnail
If you're using Sigil you can use its TagMechanic plugin, which is essentially the same as the Editing Toolbag that JSWolf pointed to.

I'd forgotten about the strong tag; google brought up this article: https://www.seobility.net/en/wiki/Strong_and_Bold_Tags

So you could use strong for things you want to semantically emphasize and style it as bold in your css. In fiction my experience is that when people emphasize something said it's with italics.

So now I'm confused about the difference between the strong and em tags.
There really aren't any differences between <b>/<strong> and <i>/<em>. By default they are the same. But you can change all of them in CSS. For example, you can style <i> to be bold and <b> to be italic.

In that article, it states...
Quote
Difference between strong and bold

The difference between the two HTML tags is that bold makes text only visually look bold, while strong also semantically emphasizes the respective text as important and indicates that it is a meaningful word or text section.

This distinction is due to the fact that HTML code differentiates between semantic-logical and physical-visual HTML tags. While the former refer to the meaning (semantics = theory of meaning) of the respective areas, the latter merely define the optical display in browsers.
So when you are reading your eBook and you see text that is coded like <b>Some bold test.</b> and <strong>Some strong text.</strong>, they will both appear bold. There is 0 difference. Unless you've looked at the code, you won't know if the code is <b>, <strong>, or <span class="bold">. So this saying that <strong> emphasizes the text is rubbish. Your TTS is not going to differentiate. It's not going to say bold text any different then it would strong text. This is exactly the same for <i>, <em>, and <span class="italic">.
Reply 

#6  j.p.s 10-02-2020, 09:20 PM
Quote JSWolf
That again is incorrect. <b> is not deprecated. It works perfectly well in ePub 2/3.
You misunderstand deprecated.
https://en.wikipedia.org/wiki/Deprecation

It means that it is obsolete and should not be used is in new code and will likely not be supported at some possibly unspecified future time. It has nothing to do with whether it works now.
Quote
You are better using <b> then <strong>.
Why would you use <b> if you are going change to <strong>?

Is it because you are an European?
Reply 

#7  hobnail 10-02-2020, 11:05 PM
Quote j.p.s
"You are better using <b> then <strong>."

Why would you use <b> if you are going change to <strong>?

Is it because you are an European?
I think he meant "than" not "then".
Reply 

#8  j.p.s 10-03-2020, 12:48 AM
Quote hobnail
I think he meant "than" not "then".
He is on record saying there is never any excuse for typographic errors, specifically including swapping then for than.
Reply 

#9  davidfor 10-03-2020, 07:18 AM
Quote JSWolf
There really aren't any differences between <b>/<strong> and <i>/<em>. By default they are the same. But you can change all of them in CSS. For example, you can style <i> to be bold and <b> to be italic.

In that article, it states...


So when you are reading your eBook and you see text that is coded like <b>Some bold test.</b> and <strong>Some strong text.</strong>, they will both appear bold. There is 0 difference. Unless you've looked at the code, you won't know if the code is <b>, <strong>, or <span class="bold">. So this saying that <strong> emphasizes the text is rubbish. Your TTS is not going to differentiate. It's not going to say bold text any different then it would strong text. This is exactly the same for <i>, <em>, and <span class="italic">.
After all this time, you really don't get it, do you? But, yet you would scream at someone who suggested using a <p class="chapterHeading"> where the class "chapterHeading" was the same style as a h1 or h2 tag. As you keep saying, why does it matter if they look the same on the screen?

It is about semantics. It is about letting applications such as a TTS handle them differently if it makes sense. And honestly, if the TTS isn't indicating a difference, then it is probably because far to many people who code the books have listened to you. There are semantics involved. We should be expressing them where we can. Then the software can start handling things accordingly.

@Rand Brittain: Use whichever you feel comfortable with. I personally don't like seeing <span class="bold">, but if it was <span class="telepathicSpeach"> and the class telepathicSpeach only set the style to bold text, it would make sense to me (though most people seem to use italics for that). That makes it easy to go back and restyle it later. And if <strong> makes more sense to you than <b> when you are reading the code, then do it that way. Or if <b> feels better to you, use it.
Reply 

#10  JSWolf 10-03-2020, 07:27 AM
Quote j.p.s
You misunderstand deprecated.
https://en.wikipedia.org/wiki/Deprecation

It means that it is obsolete and should not be used is in new code and will likely not be supported at some possibly unspecified future time. It has nothing to do with whether it works now.

Why would you use <b> if you are going change to <strong>?

Is it because you are an European?
Please explain to me how you can tell the difference between <b> and <strong> when reading a book? <b> is meant to be bold and <strong> is meant to emphasize something. But really, all they both do is display bold test. You can use either interchangeably. This is silly when you think of it. You cannot read <strong> text and different then you would <b> text.

Prove I'm worog and I'll agree to use <strong> and <em>. Prove to me that you can tell by reading if the text is using <b> or <strong>.
Reply 

  Next »  Last »  (1/2)
Today's Posts | Search this Thread | Login | Register